It is currently Fri Nov 22, 2024 4:09 am

'Goon Chat--On the Go (PRE-BETA!)

For game and non-game related chatter, links, and other goodies, go here.

'Goon Chat--On the Go (PRE-BETA!)

Postby Zancarius » Sun Jul 20, 2008 3:40 pm

Well, I guess it's time I let everyone know what my latest project has been. I was curious to see if it were possible to put together an AJAX-based web chat client from scratch. Turns out: It is. There's a few example implementations on the web, but in truth: They all suck. Not that mine's much better, but I found that many of the pure PHP-based versions were just awful. I wasn't about to resort to Java applets (ick!) or Flash (may as well use JavaScript). So, here we go...

http://chat.blackravendragoons.com/

There are still SEVERAL glaring bugs and problems with the software. Right now, most of these are issues related to how JavaScript handles scope (or most likely--my misunderstanding of scope). Also, most commands that I plan on implementing don't currently work nor are they implemented. And there's also a few potential issues that might crop up which I haven't yet dealt with. For instance, I don't really know what would happen if you were to try setting your nickname to one that already exists. In theory it may be possible, but it'll essentially orphan the previous nickname.

Also... the manner in which Internet Explorer handles unbuffered reads from a script isn't very pretty. The result is that it tends to lose messages that are sitting in the message queue and never bothered rendering them. I know there's a way to fix this, but since I don't have a lot of experience with writing JavaScript specifically for Internet Explorer, I don't know exactly what to do.

Nicknames are also NOT remembered between sessions. I'll work on that. Right now, you have to manually set you nickname.

Implementation details
(This is the boring cruft most of you won't really care about unless you're technically inclined, so don't read it.)

For the curious, here's how it works:

The back-end is written using Python and the Twisted Python framework. This interfaces with the client by utilizing very small PHP scripts that pass session information (that they generate) directly to the back end to maintain some notion of "state." HTTP doesn't support "push" type protocols, so all events have to be handled asynchronously. This means that whenever it looks like you're receiving a message from the server, you're not. Your client is actually connecting the server every second on the "get" script. While your client is idling, the server adds messages received for the channel (and for you) into a queue. This queue is sent when your client "wakes up" and asks the server for messages you've received. On the other hand, when sending a message, your browser sends the data directly to the server which then interprets it and dispatches it to the recipient(s).

So really, it's a very convoluted means of writing a chat server, but it's about the only way to do it well using AJAX. "Streaming" works (in the sense of never closing the HTTP connection)--if you're using Firefox and Opera. Internet Explorer refuses to work with this technique, because it won't actually parse or render anything until the connection is closed--so that little tidbit kinda sucks. Anyway, we'll see what happens. I don't imagine there'd be a huge load, because the back-end doesn't use a network connection to communicate with itself (it does use UNIX domain sockets, though).

Anyway, poke around with it. It might be interesting to see what we can do. ;)
I gave that lich a phylactery shard. Liches love phylactery shards.
User avatar
Zancarius
Site Admin
 
Posts: 3907
Joined: Wed Jul 05, 2006 3:06 pm
Location: New Mexico
Gender: Male

Postby Zancarius » Sun Jul 20, 2008 4:54 pm

Bug Report Filing

You can file bug reports at:

http://trac.destrealm.org/cited

Trac is a bug tracking, feature tracking ticket-based system that allows anyone to generate new requests. You can also use Trac to browse the source code in real-time.

Obtaining the Source

As always, you can access the source from my Subversion server:

Windows network neighborhood, instructions for Windows XP but can be adapted to other Windows-based OSes:

Click on "My Network Places."
Double-click "Add Network Place."
Click next.
Select "Choose another network location" and click next.
Enter the URI: http://svn.destrealm.org/cited/trunk/
Click next.
Enter a descriptive name, such as "Cited" and click next.
Change options as desired and click finish.

Subversion (using svn):

Change to an empty directory for the repo.
Type: svn co http://svn.destrealm.org/cited/trunk .

Done. ;)

Tortoise SVN (Windows svn shell interface):

Create or browse to an empty directory using Windows explorer. You should probably create a separate directory named "cited" and browse to it.
Right-click in the file pane and select TortoiseSVN -> Checkout.
Enter http://svn.destrealm.org/cited/trunk into the "URL of repository."
Click okay.
Cited will be checked out into the current directory.
Last edited by Zancarius on Mon Jul 28, 2008 1:12 am, edited 1 time in total.
I gave that lich a phylactery shard. Liches love phylactery shards.
User avatar
Zancarius
Site Admin
 
Posts: 3907
Joined: Wed Jul 05, 2006 3:06 pm
Location: New Mexico
Gender: Male

Postby Grimblast » Sun Jul 20, 2008 7:23 pm

You sir are a fucking genius!
Guild Wars 2 Characters
Turalia Gearspark - Asuran Engineer ----------- Turus Gearspark - Asuran Guardian
Thelena Turusian - Norn Warrior ---------------- Jake Turusian - Human Thief
Dililah Turusian - Norn Necromancer ------------ Rahl Braincrusher - Char Mesmer
Star Earthbreaker - Sylvari Elementalist -------- Rylo Preystalker - Char Ranger
User avatar
Grimblast
Site Admin
 
Posts: 2513
Joined: Wed Jul 05, 2006 3:21 pm
Location: Alamogordo, New Mexico
Gender: Male

Postby Zancarius » Sun Jul 20, 2008 7:32 pm

Some intermediate observations:

The poll frequency is an the order of about 1 second. This seems to do okay on connections that have relatively low latency to the server. However, it seems to cause a bit of a backlog on connections with a relatively high ping to the 'goon machine, and seems to increase perceived latency on those clients. I haven't been able to confirm this personally, but this issue was reported by Aspe. The solution I can see for this is to bump the poll interval up. (This will be a user-configurable option in the next UI revision.)

The UI also has some minor problems with width assignments for lower resolutions. This isn't too much of a problem if your window is fairly large, but on screen resolutions < 1024x768, you'll start to notice it. The height assignments are currently fixed at around 300ish pixels, but some feedback I've received suggests it should probably take up the whole screen. Thanks to Haiku for pointing this out.

Also, one of the more annoying bugs (actually, the result of a feature I haven't implemented yet) involves trying to copy from the chat window. The script updates the scroll location to the bottom every second, so if you try to copy, you'll find that the scroll location resets and all the highlighted text unhighlights. You can work around this by highlighting text and while holding the mouse button down, you can press ctrl+c. My solution to this problem will be to disable the scrolling while the chat window has focus. We'll see what happens.

Bear in mind, this is a pre-beta. As a result, lots of stuff isn't implemented or working.
I gave that lich a phylactery shard. Liches love phylactery shards.
User avatar
Zancarius
Site Admin
 
Posts: 3907
Joined: Wed Jul 05, 2006 3:06 pm
Location: New Mexico
Gender: Male

Postby Tirian » Tue Jul 22, 2008 11:45 am

You obviously have too much free time. What did you do, quit WoW?
Letting the demon do the work for me since 2004.
I play to some degree: WoW (EU now, US before), Guild Wars 2 (EU), SWTOR.
User avatar
Tirian
Officer
 
Posts: 802
Joined: Fri Dec 07, 2007 5:16 am
Location: Moscow
Gender: Male

Postby Zancarius » Tue Jul 22, 2008 2:26 pm

>.>
I gave that lich a phylactery shard. Liches love phylactery shards.
User avatar
Zancarius
Site Admin
 
Posts: 3907
Joined: Wed Jul 05, 2006 3:06 pm
Location: New Mexico
Gender: Male

Postby Tarlas » Tue Jul 22, 2008 5:37 pm

Sweetness!!! You are the programming diety
User Avatar
Tarlas
 

Postby Zancarius » Tue Jul 22, 2008 7:26 pm

I'm actually very good at breaking things, which I've managed to do this evening. (My current working copy of it is horribly broken.)

But, I guess that's progress for you. You fix things so you can break them again.
I gave that lich a phylactery shard. Liches love phylactery shards.
User avatar
Zancarius
Site Admin
 
Posts: 3907
Joined: Wed Jul 05, 2006 3:06 pm
Location: New Mexico
Gender: Male

Postby Grimblast » Tue Jul 22, 2008 7:44 pm

The basis of problem solving of all kinds Thal
It's a dirty job but someone has to do it! :roll: :twisted:
Guild Wars 2 Characters
Turalia Gearspark - Asuran Engineer ----------- Turus Gearspark - Asuran Guardian
Thelena Turusian - Norn Warrior ---------------- Jake Turusian - Human Thief
Dililah Turusian - Norn Necromancer ------------ Rahl Braincrusher - Char Mesmer
Star Earthbreaker - Sylvari Elementalist -------- Rylo Preystalker - Char Ranger
User avatar
Grimblast
Site Admin
 
Posts: 2513
Joined: Wed Jul 05, 2006 3:21 pm
Location: Alamogordo, New Mexico
Gender: Male

Postby Zancarius » Thu Jul 24, 2008 3:48 pm

/bump

Okay, most fairly common features now work and several bugs have been removed. The "currently in channel" user list is still broken, but that's a client-side problem. (It also means I have to work up the motivation to fool around with the JavaScript a bit more--oh well.) At least the server-side understanding of the channel list is pretty usable.

Anyway, here's the commands that now work:

/quit <message>
/topic <topic>
/who <user|channel> (Requires EXACT match--partial matching isn't supported yet. Leaving the parameter blank shows who is active in the current channel.)

If the userlist (box to the right) doesn't show anyone, you can refresh it and it'll sort of start working. The JavaScript for this is really flaky. This little bit also does not work under MSIE at all. It just keeps appending to the list (thank you, Microsoft).
I gave that lich a phylactery shard. Liches love phylactery shards.
User avatar
Zancarius
Site Admin
 
Posts: 3907
Joined: Wed Jul 05, 2006 3:06 pm
Location: New Mexico
Gender: Male

Postby Killemal » Thu Jul 24, 2008 9:05 pm

Image
Image
User avatar
Killemal
Retired Goon
 
Posts: 272
Joined: Sun Feb 03, 2008 1:54 pm
Location: Boston Mass, Kid.
Gender: Male

Postby Zancarius » Thu Jul 24, 2008 9:25 pm

In true 'goon form.
I gave that lich a phylactery shard. Liches love phylactery shards.
User avatar
Zancarius
Site Admin
 
Posts: 3907
Joined: Wed Jul 05, 2006 3:06 pm
Location: New Mexico
Gender: Male

Postby Snobal » Fri Jul 25, 2008 5:41 pm

Thal...


Omg...


/bow
Image
Image
User avatar
Snobal
Officer
 
Posts: 1171
Joined: Wed Jul 05, 2006 7:48 pm
Location: This hell hole, Georgia
Gender: Not specified

Postby Zancarius » Mon Jul 28, 2008 1:11 am

More updates! But first...

Bug tracking (tickets) can be posted to: http://trac.destrealm.org/cited if you're interested. You can also go here to visually browse the code. I'll be adding this link to the main thread for anyone who might be curious about assisting with development.

Features--the Good Stuff

Random per-user colors have been added. Turus made this suggestion about a week ago, and I finally got around to it. Since colors are completely chosen at random, there is the possibility that the client may wind up picking identical colors for multiple users. There's also the possibility that the random colors may wind up being very similar to your own (your color will ALWAYS be blue). There are some limitations to these colors, so colors close to blue shouldn't be picked, and colors that are "too bright" should also be avoided.

You can now turn timestamps off and on using a radio button. This operation is performed tag-by-tag, so if you have a fairly large chatlog, toggling timestamps may be a fairly process-intensive operation.

Timestamps will now ALWAYS appear on output by default, rather than for messages.

You can now change the poll interval of the client. By default, the poll interval is set to 2 seconds. If your connection enjoys low latency, you can reduce the poll interval to as little as one second. Likewise, if your connection suffers from relatively high latencies, you might want to increase the poll interval to 2 seconds or more. AJAX sucks for things like chat, so the performance of your client is directly correlated to your latency. Higher latency means that your client may miss chat messages with shorter poll intervals.

Auto-throttling has been enabled and is still considered experimental. How this works is that when you tab out from your web browser (or switch to a different tab in the same browser), the chat client will take note of your activity. If you come back to the chat client within 10 seconds, the client will continue polling the server at your set interval (see above). However, if you stay away from your chat client for more than 10 seconds, the poll interval is automatically throttled to once every 20 seconds. Then, when you come back to the client, the poll interval is reset and you receive all messages that have been waiting in queue for your client. This means that you could feasibly receive hundreds of chat messages every 20 seconds while you're tabbed out (but this isn't too much of a big deal since it's the poll rate, not the data sent that affects your client the most). This is still a potential problem, and I might set up a flag that users can set that will allow them to log their messages while they're gone so they can retrieve them from a separate URL. Or maybe even something like /nomessage where any messages destined for that client are trashed until the command is sent again... I'm not too sure what the best option might be, so we'll see how this affects your clients.

No new commands have been added this round.

Bug fixes

Several bugs have been fixed. The only ones I can remember off-hand are:

Topics no longer appear twice when you first log in to the server.

I left some debugging code in several revisions back when I was trying to enable streaming for Internet Explorer (before I learned that it just doesn't work), so the PHP script that shuttles database between your browser and the server was sending about 3KiB of data every poll. This doesn't sound like much, but when you're polling every two seconds, this can generate in upwards of 5-10MiB over the course of an hour while doing absolutely nothing when no one is on the server. Don't get me wrong, the current setup isn't much better because you still receive data from the web server that I can't stop from being sent, but this makes things a bit more efficient.

Some outstanding, known bugs:

The user list still doesn't work. I'm getting around to that, but I haven't found a reasonable manner in which to get it working for both Firefox and MSIE.

Soon to be implemented features

More appropriate /who commands.

Better access control for /topic commands.

/kick, /kill, and /ban commands.

/op command to grant specific users operator status in the channel.

Working /join and /part commands for creating/joining new channels.

And the most important feature yet: Remember each user's login.
I gave that lich a phylactery shard. Liches love phylactery shards.
User avatar
Zancarius
Site Admin
 
Posts: 3907
Joined: Wed Jul 05, 2006 3:06 pm
Location: New Mexico
Gender: Male

Postby Zancarius » Tue Jul 29, 2008 7:53 pm

The chat server will be offline while I attempt to resolve some issues from the latest commit.
I gave that lich a phylactery shard. Liches love phylactery shards.
User avatar
Zancarius
Site Admin
 
Posts: 3907
Joined: Wed Jul 05, 2006 3:06 pm
Location: New Mexico
Gender: Male

Next

Return to General Chat

Who is online

Users browsing this forum: No registered users and 22 guests

cron