Sunday, March 22, 2009

Comet and Server Push (Reverse Ajax) technology

I am re-implementing an ajax based chat system. Presently an ajax request is polled continuously to look for any updates/messages from the user’s browser. However, the plan is to use the server to push the messages to the clients to off-load the server from a huge number of useless ajax calls.

I learned about Comet and found it interesting. You may read about comet here at WIKI.

Juggernaut is a rails plug-in that uses Flash to implement the server push technology. It is simple and it produces RJS script for the client. So, it can be used many other scenarios where a live update is required. of course, chat system is a good place for this.

The installation required a few tweaks as follows:-

  1. 1. Installed json_pure gem instead of json. (gem install json_pure)
  2. 2. Installed EventMachine gem (gem install eventmachine)
  3. 3. Installed juggernaut gem (gem install juggernaut –-ignore-dependencies)
  4. 4. Modified the C:\ruby\lib\ruby\gems\1.8\specifications\juggernaut-0.5.7.gemspec in places to the following

s.add_runtime_dependency(%q<json_pure>, [">= 1.1.1"])
s.add_development_dependency(%q<hoe>, [">= 1.3.1"])

s.add_dependency(%q<json_pure>, [">= 1.1.1"])
s.add_dependency(%q<hoe>, [">= 1.3.1"])

s.add_dependency(%q<json_pure>, [">= 1.1.1"])
s.add_dependency(%q<hoe>, [">= 1.3.1"])

since, you do not find the required versions of all the gems, you need to change this checks to get a way.

Then, this readme helped me to get started.

Will follow up this post as I work more on this. Have a good day!