Go, Ruby, and iPhone
9 months ago
Tweet this Bookmark and Share

Rayeux - Cometd/Bayeux for Ruby

For those new to the topic, Comet is a communication pattern used to push messages from web applications to web clients. "Bayeux":http://svn.cometd.com/trunk/bayeux/bayeux.html is a formal protocol for implementing these kinds of message channels. I use Bayeux extensively on "GoShrine":http://goshrine.com to make sure players get the most lag-free game playing possible. This works great for users visiting via browsers, but I also have a bot running "GNU Go":http://www.gnu.org/software/gnugo/. Up until a few days ago, I've had to run an entirely separate messaging system using "ActiveMQ":http://activemq.apache.org/ to handle interfacing and sending messages to the bot. Having two paths through the server code; one for normal players, and one for bots, complicated things and increased my memory usage by requiring ActiveMQ. I also want to give out the code that interfaces GNU Go with GoShrine, so other people can run bots on GoShrine. Using ActiveMQ would require them to have another port open to GoShrine, which might be an issue depending on where they want to run the bot, and what firewalls it would be behind. So I ported the dojo javascript cometd client over to Ruby, and called it Rayeux. You can get it at github at "http://github.com/ps2/rayeux":http://github.com/ps2/rayeux. I'm not super happy with the name, but whatever; it works. There's an example included for interfacing with the chat room demo that comes built in to Jetty, if you want to play with it. If you have an application that requires low-latency event delivery to various web clients, I'd recommend you check out Rayeux, and Cometd. I've tried a lot of different solutions to this problem, and am feeling pretty happy having this unified messaging architecture. The data is all JSON encoded, which makes it really easy to consume and generate in both javascript and Ruby.

blog comments powered by Disqus

I'm a software engineer enjoying work in both Ruby & Rails and the iPhone platform. I've published a couple of iPhone apps now: Spectrogram and CricketSong, and have a couple more in the pipeline.

Creative Commons License

All content on this blog is available under the Creative Commons Attribution 3.0 License. littleblueplanet.net is running Kakuteru a new Semantic-Web enabled lifestreamer. Design and interaction inspired by Yonfook's Sweetcron. Most icons used are by Joseph North.