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/node/view/id/1234

“Part 2:Prototype, Scriptaculous, Application HTML”:http://devzone.zend.com/node/view/id/1280

“Part 3:Storage Medium, XML and the Message Process”:http://devzone.zend.com/node/view/id/1326

“Part 4: IndexController MessageAction() and JSON Encoding”:http://devzone.zend.com/node/view/id/1387

“Part 5: The Javascript, Sending Chat Messages, Screen Name Changes”:http://devzone.zend.com/node/view/id/1407

“Part 6: Updating the User List”:http://devzone.zend.com/node/view/id/1532

“Part 7: Usability Improvements”:http://devzone.zend.com/node/view/id/1580

Published: January 15th, 2007 at 3:08
Categories: Tutorials, Zend Framework
Tags: , , , ,

3 comments to “Ajax Chat Tutorial”

_____anonymous_____
January 24th, 2007 at 12:56 pm

Function handleRefresh in part 5 contains very messy code ;-)

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

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.