Welcome to Working With Rails


Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
Chatting Program
6 Posts
Chatting Program

Can anyone direct me on how to create a chatting program using RonR?

Hi Richard,

Give a try to juggernaut (http://juggernaut.rubyforge.org/)

It's pretty easy to set up and after that you can push whatever you want from the server to the client, so it's perfect for a chatting system.

Whatever you do will probably involve heavy use of JavaScript in one way or another, and I'm not sure Rails will make it any easier.

Well, using a lot of javascript is one of the options, and using just a bit is another ;)

With the solution I proposed, juggernaut, you can get a very simple chat almost without javascript. Your view only contains a form_to_remote, to submit your chat lines to the server.

For broadcasting the chat messages to the clients there is only one javascript involves, and it's made from a RJS script, so it's actually very easy (and yes, Rails does help with that). The line is

page.insert_html :top, 'chat_data', "#{h params[:chat_input]}"

That's all the code you need for a chat room. Doesn't get much easier than that, I'd say.

You can also create new channels, update users by id, and some other nice features.

Give it a try, they have the chat example at the website and it's really very easy.

Another hybrid approach is to combine technologies. For the site http://www.bunnybot.com/, we had a core RoR application that implemented supplemental APIs (for games, account mgt, etc), and ended up using XMPP (Jabber) for everything. The Jabber gateway we were using was the OSS OpenFire server (igniterealtime.org), and after a lot of experimenting, we used an Actionscript core for the in-browser client (using XIFF).

For some integration experiments with other Social Net apps, we went the route Javier mentions (lightweight forms/JS where possible, using RoR as UI generator, and having back-end Jabber daemons running on BackgrounDRb v2)

Thanks for all the suggestions. Can juggernaut, or Jabber handle a chat room with about 100 people or more?

6 Posts
Login to add your message