Sinatra example using EventSource (Server Sent Events)
Original code from: https://gist.github.com/maccman/2992949
Server Sent Events are an awesome api that lets you push data asynchronously directly to your clients.
A polyfill for EventSource is available (thanks IE), please check:
gem i bundler bundle
(you need to have Redis installed)
On ubuntu you can install redis by:
apt-get install redis-server
bundle exec rackup
Then from your console:
redis-cli publish message hello
Voila', you shoul see your message in every browser window you have open.