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 is a formal protocol for implementing these kinds of message channels.
I use Bayeux extensively on GoShrine 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. Up until a few days ago, I’ve had to run an entirely separate messaging system using ActiveMQ 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. 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.



