114

I've done some research into server push with javascript and have found the general consensus to be that what I'm looking for lies in the "Comet" design pattern. Are there any good implementations of this pattern built on top of jQuery? If not, are there any good implementations of this pattern at all? And regardless of the answer to those questions, is there any documentation on this pattern from an implementation stand-point?

willurd
  • 10,421
  • 5
  • 26
  • 22

8 Answers8

78

I wrote the plugin mentioned by Till. The plugin is an implementation of the Bayeux protocol and currently supports long-polling (local server via AJAX) and callback-polling (remote server via XSS). There is a Bayeux implementation for Python called cometd-twisted that I have heard my plugin works with, but I have not verified this. I have tested and verified it works with cometd-jetty and erlycomet which has a jQuery Comet example included. There is more info on my blog and the current code with a basic chat example can be found on its google code page. Hope this info is helpful and feel free to contact me if need any further help with the plugin.

Morgan ARR Allen
  • 9,729
  • 2
  • 29
  • 32
  • 1
    Nice work on the plugin, works great for me. – camflan Sep 26 '08 at 19:14
  • 3
    Plugin mentioned by Till: http://plugins.jquery.com/project/Comet – Asad R. Mar 16 '11 at 08:35
  • 9
    Please know that plugin is quite old and no longer maintained. [Cometd](http://cometd.org/) now packages their own JS lib along with a jQuery interface plugin. – Morgan ARR Allen Mar 21 '11 at 20:43
  • Hi am trying to use the plugin with ASP.NET and am a newbie to comet. So could u please share some tutorials/documentations/demos of your plugin. when i click on Read Documentation in JQuery plugin site, it takes me to ur home page, but i cant find any documentation there. Pls help me. – Raghav May 31 '11 at 11:20
15

Someone built a client for Comet using jQuery. I don't know if it's any good though. I've read about Comet and heard about all the good it can do, but I have never gotten around to using it. Just had no time and no use case on any of my current projects.

I totally forgot to add a link as for implementing comet.

There is Comet Daily and they have a comparison online. The comparison emphasizes on maturity of the different implementation. It's pretty interesting and should get you started.

Hope that helps!

Till
  • 21,590
  • 4
  • 55
  • 86
9

Check out the Ape Project for a complete client and server side solution that implements the comet pattern.

Devon
  • 5,670
  • 4
  • 36
  • 45
7

A description of the pattern: http://ajaxpatterns.org/HTTP_Streaming

Jonathan Tran
  • 14,594
  • 9
  • 57
  • 64
3

Comet is a great solution, and there are all kinds of implementations. Which one depends on your needs.

We've implemented a solution for IIS/ASP.NET, WebSync. It includes the javascript client, which plays nicely with jQuery. Technically, since it's the Bayeux protocol, any Bayeux client should work just dandy. The same protocol can also be found in the dojo library.

For more detail, you can see the spec for the Bayeux protocol.

jvenema
  • 42,243
  • 5
  • 64
  • 107
3

I have a very simple example here that can get you started with comet. It covers compiling Nginx with the NHPM module and includes code for simple publisher/subscriber roles in jQuery, PHP, and Bash.

http://blog.jamieisaacs.com/2010/08/27/comet-with-nginx-and-jquery/

A working example (simple chat) can be found here:
http://cheetah.jamieisaacs.com/

Jamie
  • 784
  • 7
  • 13
3

Look at socket.io. Trust me. This is exactly what the doctor ordered.

http://socket.io

Stream data with Node.js

Community
  • 1
  • 1
BMiner
  • 14,934
  • 11
  • 47
  • 52
2

If you're using JQuery, I'd recommend jquery-stream. I'm currently using jquery-stream on a project and so far its been reliable, well-documented and has an active Google code project.

http://code.google.com/p/jquery-stream/

Dan Garland
  • 3,003
  • 1
  • 21
  • 23