Archive for the ‘Bayeux’ Category

New Cometd client and server demo

Friday, November 7th, 2008

On and off for the last couple weeks I have really been pushing myself to learn Java better. I constantly find myself unable to do things I want to with the languages I usually use (PHP specifically). As I am getting better I am coming to like it a lot more. As any reader of my blog (do I actually have ‘readers’?) know, I am really into Cometd, which the most major implementation of is written in Java. So in order to utilize Cometd Java and push my jQuery plugin further along, I figured it was high time I learn Java. I am really glad I am too. Just in time for my new Android phone too :)

CometdMap
Almost every demo of Cometd out there is a chat application, next up is stock tickers. There are one or two more I can think of off hand, none of which could be made into something more useful. I have had an application idea in the back of my head for quick some time. I really like doing work with maps, have been doing professional Google Maps work for a couple years, had to get the (second) dorkiest bike computer with GPS to map my rides. I have wanted for some time to do a real-time map. CometdMap is a proof of concept of that. It has no actually data input at the moment, infact, it is really basic right now. What it really does is show how simply you can build a Cometd Java app. I was really surprised at how easily I built this with my limited knowledge of Java.

What does it do
Right now, if you build and run the application you will get a simple Google Map. Clicking on the map will place a marker. Wowee! Pretty basic yeah, but what is going on here. Clicking the map publishes the point to the server, it is not until the server returns the data to the subscription callback that it is added. That is about all for the client side. On the server side two things are going on. First, when a new client joins they are added to a list, very similar to the way the Cometd Chat demo handles clients for private messages. Second, when points are published they are tracked on another list. So what can we do with these lists? Add a couple points and reload your browser. Since you are now a new client and there are points on the list, the old points are sent back to you. This will work for any new clients joining also. With multiple clients connected markers are updated to each in real-time.

Download & Build
Download
As I have mentioned before, the Java build environment and I do not exactly get along. In the tarball there is a script call build (partially ripped from the Harmony build script). If you have built the Cometd demo from Jetty with Maven this script should work just fine. Otherwise change the paths in the build (and server) scripts to point to the directories where your Jetty and Comet components are.

Enjoy, hopefully everyone is able to build with few problems. Check back in a couple weeks to see what I have in store next. Cheers, Morgan.

jQuery Comet update (finally).

Tuesday, September 9th, 2008

Now that I am semi-settled in here in Berlin (anyone have a room for rent? (cheap)), I am trying to get caught up on stuff. I finally pushed some fixes suggested by Jörn and got the chat demo reported. Its all in the SVN at Google Code and setup an external item in the jQuery SVN. Also sent an email to Greg Wilkins today, hopefully I can get this into the Cometd SVN also.
Next release will be a total rewrite, I made a lot of mistakes in the original, and the prefer jQuery plugin style has changed. Getting back to this point will not be too difficult, and well worth it.

jQuery Comet in the wild

Monday, February 4th, 2008

I am really exited about recent talks I have had with the Erlycomet team, and now they are including an early version of the jQuery cometd plugin as one of their demo options! I am working now to include some code they contributed in the main distribution. I also setup a Google Code project with the latest SVN. I am really exited about all of this, and hope to see more interest and contributions to the project.

Callback polling

Monday, January 21st, 2008

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.

Phomet: A PHP Cometd publisher

Friday, January 11th, 2008

Created 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, 2008

New 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, 2008

I 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.