Ajax – Advanced chat web-app

ajaxchatcometgmailxmpp

I am looking to implement something similar to facebook/gmail chat. I know they use comet & jabber as their technology. But am confused about a couple of things.

  1. Do i really need jabber? Can I instead use a simple mysql table with from, to, message, sent and recd? Are there any inefficiencies in using mysql? Is there any performance loss?

  2. Can comet be implemented using regular web-servers? Do i need to have some special servers? AFAIK, apache+php cannot handle too many open connections? Should I use simple polling, will that have an adverse effect on my system? What can I use out-of-the-box on ordinary webhosts? (Cause if i sell the chat app, it should work for most people.)

  3. Which is the best way (currently) to implement comet? Is the infinite iframe a good idea? Wont php timeout after a while? Will it be a cross browser solution or do i have to write some ugly hacks? Will that lead to server load? What do gmail and facebook use for the forever connection?

Best Solution

Great questions, hopefully this won't get lost in the stack on the weekend. If you want to use flash kirupa has a good tutorial on how to use PHP and sockets. As far as comet goes, I believe you have to have some sort of server implementation. That is about where my feeble knowledge ends right now.

Simple polling example (jquery + asp.net) http://trappedinhoth.blogspot.com/2009/04/ajax-jquery-chat-demo.html

Kirupa's tutorial (php5 sockets + flash 8) http://www.kirupa.com/developer/flash8/php5sockets_flash8.htm

Open source flash chat client (google, plenty more) https://blueimp.net/ajax/

Comet info http://cometdaily.com/

I'm not really answering your question, just pointing you to more resources. I'm very curious as to what others will answer.