simon's weblog

mercoledì lug 29, 2009

JavaScript Cometd Implementation Refactored

The Dojo project has pioneered the implementation of the Bayeux specification, but for example the jQuery project lacked a robust client-side Cometd implementation.

This gap has been filled now, with a shared pure-JavaScript implementation and bindings for both Dojo and jQuery.
This means that the bulk of the Cometd implementation is now in a single, pure-JavaScript file, and that users of either toolkit have a binding (a very small adapter code) that allows developers to use the JavaScript Cometd API as a first class citizen in the either toolkit.

As a small example, this is how you use it in Dojo:

dojox.cometd.publish('/mychannel', { mydata: 'foobar' });
and this is how you use it in jQuery:
$.cometd.publish('/mychannel', { mydata: 'foobar' });

A good side effect of all this is that every bug or new feature is fixed or added to the shared pure-JavaScript file, and immediately both toolkits will benefit of that.

The implementation has been totally rewritten since the one historically present in Dojo, and the following are the most interesting features:

  • better support for tweaking the configuration
  • split configuration and initialization steps to allow more flexibility in case of programmatic disconnects
  • extended and clarified the Cometd APIs
  • better notifications for failures due to server or network failures
  • automatic and configurable connection retries
  • incoming message and outgoing message interception
  • automatic bayeux transport negotiation, supporting long-polling and callback-polling transports
  • extensions such as timesync, message acknowledgement and transparent page reload

Downloads, documentation and code is available at the Cometd website.

Comments:

Post a Comment:
  • HTML Syntax: Allowed

Webtide

Calendar

Tags

Search

Links

Navigation