Comet is coming

In a recent article in which I wrote about the HTML 5 draft, I mentioned a server notifications API and hinted that it will standardize a technique known as Comet. So what is Comet anyway?

Comet is an event driven communication scheme with between a web-browser and a web-server. In the normal flow of an http request, a web server can not initiate communications with the client (the web browser) - it can only respond to requests. Comet declares a reversal of roles, in which the server can notify the client whenever new data is available. This technique is very useful in a constantly changing environment such as stock prices or online messaging (chat).

The term was coined by Alex Russell of Dojo fame, in a blog piece a little more than two years ago. It has since gained minor traction in the development community, with several projects actively promoting it and educating on it. It never reached AJAX-levels in popularity though, mainly due to it being somewhat difficult to implement and use.

Enter HTML 5. The working draft of the HTML 5 specifications declares server-sent DOM events. This API allows for native implementation of Comet techniques without using elaborate client-server setups which will finally make Comet accessible enough to be considered mainstream. The specs go even further, and declare an interface for bidirectional communications between client and server and client and client (P2P). Such an interface would render current AJAX techniques absolute, as the XHR object would no longer be required to poll the server for data on demand. The peer-to-peer options offer an incredible opportunity to multi-user environment by removing the server as the middle-man (and the bottleneck).

Comet Daily gives an overview of this API and the WebSockets API in a recent piece. Michael Carter mentions the new network API and how it will affect future client-server communication in some detail and even shows some mock code of ridiculously simple setup for server-listening events.

So yeah, HTML 5 is definitely something to watch for. Hopefully the draft will be finalized as soon as possible so browser vendors could start pushing out implementations and make us developers very happy.

To know when the next article is published, please subscribe to new articles using your Email below or follow me on Twitter.

Subscribe to Blog via Email

Enter your email address to receive notification about new posts.

  • http://www.orbited.org Michael Carter

    Its worth noting that the HTML5 draft need not be standardized for browser vendors to start implementing the features. This has been the case for a number of features already, and I expect it to be similar for WebSocket. Before the year is out we may very well see implementations in the development branches of major browsers.

  • http://www.orbited.org Michael Carter

    Its worth noting that the HTML5 draft need not be standardized for browser vendors to start implementing the features. This has been the case for a number of features already, and I expect it to be similar for WebSocket. Before the year is out we may very well see implementations in the development branches of major browsers.

  • http://www.techfounder.net Eran Galperin

    One can only hope! :)

  • http://www.techfounder.net Eran Galperin

    One can only hope! :)

  • http://codeutopia.net Jani Hartikainen

    Yep, it’s going to be interesting to see what people can come up with when Server-Sent Events is widely adopted.

    Opera has already supported SSE since 9.something, and I’ve actually written a full client-server type of solution using it for a JavaScript based tank game. I wrote the server in Python and the game used XMLHttpRequest to send data and SSE to receive.

  • http://codeutopia.net Jani Hartikainen

    Yep, it’s going to be interesting to see what people can come up with when Server-Sent Events is widely adopted.

    Opera has already supported SSE since 9.something, and I’ve actually written a full client-server type of solution using it for a JavaScript based tank game. I wrote the server in Python and the game used XMLHttpRequest to send data and SSE to receive.

  • http://www.techfounder.net Eran Galperin

    The most interesting aspect to me is the possible matching of clients directly (P2P) – that will reduce so much load from servers today for multi-user environment and open up a whole new range of possible uses.

    That tank game sounds interesting, any chance it’s available as open-source? ;)

  • http://www.techfounder.net Eran Galperin

    The most interesting aspect to me is the possible matching of clients directly (P2P) – that will reduce so much load from servers today for multi-user environment and open up a whole new range of possible uses.

    That tank game sounds interesting, any chance it’s available as open-source? ;)

  • http://codeutopia.net Jani Hartikainen

    It’s downloadable from http://widgets.opera.com/widget/5988/ though it seems it doesn’t work 100% correctly in latest Opera versions (The implementation for canvas has changed a bit I think), and the online server died and was lost completely when my home-server’s HDD crashed.

  • http://codeutopia.net Jani Hartikainen

    It’s downloadable from http://widgets.opera.com/widget/5988/ though it seems it doesn’t work 100% correctly in latest Opera versions (The implementation for canvas has changed a bit I think), and the online server died and was lost completely when my home-server’s HDD crashed.

  • http://www.mxtrio.com Ernesto Ruy Sanchez

    I’ve seen COMET in action for quiete some time in Mibbit. An AJAX IRC client, take a look at it here http://www.mibbit.com.

  • http://www.mxtrio.com Ernesto Ruy Sanchez

    I’ve seen COMET in action for quiete some time in Mibbit. An AJAX IRC client, take a look at it here http://www.mibbit.com.