chat room theory and development
Moderator: General Moderators
chat room theory and development
I recently built a chat application with php/mysql/ajax, but I'm hoping I can find some advice on how to make it better. The user types their comment and presses submit; I used ajax to add the value of the comment box to my database with an onclick function. Meanwhile, a body onload ajax function updates (every 500 ms) the div where the conversation is taking place. My ajax works fine; the php scripts all do what I want them to do. Essentially, the conversation div updates often enough to where when the user presses submit, their comment appears to wind up in the conversation div instantly, but it really only gets put in the database. So, I tested it out online with a friend and there were some time delay issues. My friend said sometimes their comment didn't go through and the javascript timing seemed erratic, i.e. as if 500 ms wasn't the same every time. We were using different browsers on purpose to test cross browser compatibility, so that may be part of it and I'm sure internet connection speed is a factor. Since I have some experience with flex apps, I thought I'd try and build a flash chat room. However, I'm not even sure my whole theory on how chat rooms work is sound. Does anyone have any experience or knowledge in this area? For instance, I've read about networked game programming with java, where the "state" of the game is updated in all instances of the program; I can see how this might be used in a chat application. Anyways, I apologize for the length of this post. Lol. Thanks in advance!
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
Re: chat room theory and development
winded... there are java based chat applications that work using irc. maybe you could find some inspiration there.
Re: chat room theory and development
Take a look at:
http://en.wikipedia.org/wiki/Comet_(programming)
I would advice you to use a "long polling" approach.
http://en.wikipedia.org/wiki/Comet_(programming)
I would advice you to use a "long polling" approach.
There are 10 types of people in this world, those who understand binary and those who don't
Re: chat room theory and development
There are 10 types of people in this world, those who understand binary and those who don't