0

Ok, here's the catch: i am using ExtJS + PHP + MySQL to make a real-time chat site, based solely on AJAX requests. Yea, reverse AJAX would be cooler, but i haven't met anything easy to use enough to incorporate. (maybe you could suggest something !)

The site would be comprised of a buddy list, windows to talk to buddies, and a toolbar-menu-thing. Each user would have a buddy list. Each user would need to periodically update the 'online-ness' of their buddies through ajax, and each user would need to periodically check to see for new messages.

Hence, the DB has to be able to supply two things: new messages, and online-ness of the people in the buddy list. So, each user has to provide messages and online-ness to the database, in order to be distributed to the interested users.

The main issue in all this SQL and AJAX soup is how do you do that? Sending messages is easy: when FRED sends a message to WILMA, a new row in the table 'messages' is created, containing the name of the sender, receiver, message, and timestamp. WILMA's ajax checks for new messages, and queries the DB each 0.4 seconds or so for new messages.
But what about online status ? How does a user tell the server 'hey, i'm still here !'. And how do you distribute that to the rest of the users?

One idea is that everytime a user polls for new messages, he also queries the DB to update a table, in which his last poll's timestamp is stored. There would be another table with true/false values for each user, and another application would run in parallel with the server, updating the 'online' table, based on values in the 'lastajaxpoll' table, once every 5 seconds or so. But that would be a bit too resource intensive - imagine, every 0.4 seconds, doing a double run to the database, once to poll for new messages, twice to update your last-poll timestamp. Plus every 1 or so second to update online status. Plus messages.
At 10.000 users or so, would SQL still hold together to the huge number of queries? Yikes !

Anyone got a better idea?
I must say that my experience in web programming/databases is next to null, so advices are very welcome !
Thank you !

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by TotoTitus
0

A separate table in the db, columns for user id and online status, write a php file to select latest result from table, use jquery on main html file to load() the response from the PHP file every half second or so into a div or whatever your using to hold the online status! Let me know if you need the jQuery code for the ajax stuff!

0

I fear that will not work.
I use ExtJS, and i don't want to intermingle it with JQuery.
I've done a small optimization, in which only online-ness data exchanged is the lastpoll time of the other users.

Still, if anyone out there has a super-brilliant idea, or a name for a Comet/Reverse Ajax helper, i would really like to hear : )

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.