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.
Excellent! Just yell if there is anything I can do to help with regards to the jetty servlet or explaining anything.
Thanks a lot Greg, you will most definitely hear from me as I go, I know no Java and have been having trouble understanding some of the things going on back there. But while looking over the Bayeux spec yesterday I notice the disconnect is not sending clientId back. +reply.put(CLIENT_FIELD, client.getId()); on line ~803
Wow! This is great news. No Java? Never mind… How about Python? Would this work with Orbited? Would be great to give it a try to integrate it with TurboGears then.
Orbited
TurboGears
I will look into both of those. Right now I am just trying to get it working with the cometd demos.
nice work. It would be great to see some examples with PHP/Ruby as well.
I agree. As I said before, I do not know Java very well. This does not present a problem very much right now because I am mostly porting the example from Jetty. Later when I am implementing parts of Bayeux that are not used in the examples provided, I will need a system I am more familiar with (like PHP). If you check the jQuery discussions on LIVE server pushing (and), the conversation grinds down on how to implement the loop. PHP is not very well suited (I my opinion) for event based comet. For example, do a while loop with an SQL query in it and watch mysql chew 70% CPU if it can. This is not mysqls fault, it is just not intended to be hammered like that. I have been playing with nanoserv lately and I think it may be able to handle some of the requirements to implement comet in PHP. It is an easily extended web server (nanoserv is actually a socket daemon, but I have only been working the the HTTP Handler) that can handle real time user interaction. This is essentially what Jetty is doing in Java! I would love to see some more development from sikz.But as far as implementing Bayeux in PHP, do it! Otherwise, I will when I am done with $.comet
Oh hey! I also have the chat demo almost working, I hope to get it done on the train in the morning.
just a quick comment - been messing around with comet for a while now and have actually found that php does just fine as long as you, 1. run it outside of apache on a separate port (such as tomcat uses 8080) and access it directly or, 2. have the apache server accept the initial handshake and subsequent protocol connections but immediately hand them off to the independent php process. just set up a preforking php socket server (or however you like) and it flies with virtually no memory overhead and a low and steady hum from the processor. i’ve found perl to be a bit faster even, but i’m satisfied with the results from php so i’m sticking with it.
Mark, good point. And just as I said, I think nanoserv would work great, because it is a server running on a different port. I guess I was a little too general in that comment. Hopefully we will see some more PHP work in the near future.
I’m glad I stumbled on this. I’ve been planning a game which will be using jquery as the core framework on the clientside and had been researching comet solutions out there (again) when I stumbled on this.
I’ll be following your project for sure!
Is there a demo site or server/client code sample avaliable. I am very impressed with comet. I need to send messages back to the other users when there is a action taken by one users. Its a web based application and I have used Jquery,Ajax. I need to send message to all users or specified users depending upon one user action, in a multi-user web based application.
Rav
Sounds like rav is trying to do the same thing I need to do. Demo or sample code would be amazing. And rav if you figured out how to do this on your own please post a code sample or a url, you would really be helping me out.
Thanks
Daniel
Morgan - if you have some demo code, that would be absolutely fantastic. Just a simple chat demo with comet js + php. Thank you!
Morgan, I am looking to implement similar functionality too. This is similar to what Steffen and Rav are trying to do. I would love to have a demo/sample code. If you’ve those please point them to me or could you share it with me?