I spent this last weekend in Carson CA watching the UCI Worldcup of Track Racing. Pretty amazing sight. But between races I managed to implement callback-polling in the Comet jQuery plugin. Now cross domain calls are supported. As usual you can get the code here.
Archive for January, 2008
Callback polling
Monday, January 21st, 2008Phomet: A PHP Cometd publisher
Friday, January 11th, 2008Created a small class last night that will allow you to connect, and then publish to a comet server. Code available here. Usage is simple.
$oPhomet = new Bayeux(‘http://whereis/my/cometd’);
$oPhomet->publish(‘/some/channel’, array(‘user’ => ‘derper’, ‘message’ => ‘wee’));
The deconstructor takes care of disconnected you from the server, but if you wish, you can use ->diconnect() before.
Comet update.
Thursday, January 10th, 2008New version up. Things are moving along, I am still trying to iron out the events for returning messages to proper handlers. I have it mostly working with the Cometd chat demo, but still have not had a chance to rewrite the whole chat.js from the demo for testing. So if someone is interested in giving it a test, that would be a good place to start. Source here.
$.comet
Tuesday, January 8th, 2008I have been doing a lot of research on Comet lately. I have know about this for a while, but for some reason just have not gotten around to using it. But with work I have been doing to POAL, and nanoserv and Jetty I have had trouble ignoring it, and now I love it! So I am beginning work on porting implementing Bayeux in jQuery. It is really basic at the moment, but I have gotten it to work with the Jetty 6.1.7 Cometd echo demo. I think it will work with the chat also, but I have not had a chance to rewrite the chat room demo. Here is a link to the extension so far.
To use,
$.comet.init() to setup the connection and get clientId.
$.comet.publish to send messages,
$.comet.subscribe to setup a subscription.
$(’selector’).bind(’subscription’, function(event, data) {}); to receive data back.
This is just what I have put together over the last couple day. Based on a lot of blogs I have been reading lately and even talk on the jQuery mailing list, Comet (Bayeux to be specific in this case) and going to be in high demand in the near future. Let me know what you think, and check back for more to come.