Cockatoo
Cockatoo is a simple chat server. It’s coded in Ruby with the help of the fantastic EventMachine.
There are several techniques to handle the real-time web, but we decided to use the Long Polling technique. It works with plenty of browsers.
If you don’t know EventMachine and Long Polling, maybe you can read “Long Polling with Event Machine”.
Server part
The server part is coded in Ruby and EventMachine. The protocol is pretty straightforward.
Client part
You can use any client part you want. We provide 4 components so you can setup a simple chat system in any Ruby/Rails app you’re working on :
-
_chat_initialization HAML template
-
_chat HAML template
-
chat.js is the javascript client library (you will need jQuery)
-
chat.css is the CSS stylesheet
Just include the 2 templates and the javascript lib in your layout and you’ll be good to go.
Here are two screenshots of the client side in action :
Installation
gem install cockatoo
Usage
Beware that you’ll need a “log” directory located where you will run cockatoo.
start the server (by default it will run on the 8000 port)
cockatoo start
start the server on the 9000 port
cockatoo start -- 9000
stop the server
cockatoo stop
restart the server
cockatoo restart
You will need an HTTP server in front of your Ruby/Rails app and your chat server.
In Nginx, you will have to add something like the following to your configuration file :
server {
listen 80;
server_name mywebapp.com;
root /home/rails/www/lollidays/current/public;
passenger_enabled on;
location /chat {
proxy_pass http://mychatserver:8000;
proxy_set_header X-Real-IP $remote_addr;
}
}
And in Apache :
ProxyPass /chat http://mychatserver:8000
ProxyPassReverse /chat http://mychatserver:8000
ProxyPreserveHost On
Copyright
Copyright © 2010 Novelys. See LICENSE for details.
Contributors
-
Yann Klis inital work and packaging
-
Sébastien Pierre client side HTML and CSS