Ajax Chat Tutorial

p. Creating a chat application is not a difficult task. Honest!
p. This tutorial is a step by step introduction to creating a lightweight chat application using XML as a storage medium. As personal motivation, I develop PHP games as a hobby. In pursuit of that hobby I’ve found that offering a flat threadless forum in such games tends to result in heavy usage as players attempt to use it as a chat room. The reason is that even with the advent of irc and instant messengers, users continue see an alternative web based solution as attractive for a number of reasons whether its limited access to instant messengers through a corporate proxy or simply for convenience sake.
“Part 1: Introduction, The Zend Framework”:http://devzone.zend.com/article/1234
“Part 2:Prototype, Scriptaculous, Application HTML”:http://devzone.zend.com/article/1280
“Part 3:Storage Medium, XML and the Message Process”:http://devzone.zend.com/article/1326
“Part 4: IndexController MessageAction() and JSON Encoding”:http://devzone.zend.com/article/1387
“Part 5: The Javascript, Sending Chat Messages, Screen Name Changes”:http://devzone.zend.com/article/1407
“Part 6: Updating the User List”:http://devzone.zend.com/article/1532
“Part 7: Usability Improvements”:http://devzone.zend.com/article/1580
Ajax, PHP5

About maugrim
Padraic Brady has been an open source PHP developer since 2002. After spending three years developing PHP websites on a part time basis, and being a regular contributor/security reviewer to several online PHP games, he has since gotten a high paying job reviewing internal control systems and applications with a multinational company (who shall go nameless).
Since 2004, Padraic has been working in his spare time on several PHP game projects, and has been busy developing a small PHP framework called Partholan. Plans for the future include getting a PEAR account, developing an Ajaxified Chess Server for PHP, and sharing 11+ years of programming experience with anyone willing to listen. He also contributes irregularly to several small PHP projects, the latest being ADOdb Lite.
You will most likely find Padraic hanging around on the PHP Developers Network Forum, or lurking on several game forums patiently fielding questions on game design in PHP. Padraic lives in a rural area of County Wicklow, Ireland, where he often entertains the locals with stories of how many different ways websites mangle the weird a-acute character in his name. He desperately looks forward to Unicode support in PHP 6.
Padraic maintain a blog over on http://blog.quantum-star.com.
View all posts by maugrim →
January 24, 2007 at 12:56 pm
Function handleRefresh in part 5 contains very messy code
February 3, 2007 at 7:13 am
This project works, when u r running only chat application in your site, if u have forums,wikis,videos,mp3s and all, and then if someone try to integarte this chat application, same like ‘gmail chat’ (chatting as well as mailling), then i am sure they may worried because of the speed. Because we have to ping in every 2-3 second to the server for new msg and this will definately slow the hole site.
Will any one say in this case what is the best solution…
pls mail me the solution in prashcom@gmail.com
August 15, 2007 at 8:09 am
As I see, Google is also using periodical AJAX requests in gmail interface for chat. But usually chat servers and clients are using sockets to comunicate.
Unfortunately JavaScript doesn’t supports sockets
But Flash supports and it could be used to build chat on sockets!
If you want to build chat with HTML interface (without Flash), you can use Flash as a socket gateway for JavaScript.