Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
tmp
 
 
 
 
 
 
 
 
 
 
 
 

Readme.md

Sinatra-stream Example

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.

https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events https://developer.mozilla.org/en-US/docs/Web/API/EventSource

A polyfill for EventSource is available (thanks IE), please check:

https://github.com/Yaffle/EventSource

Setup:

gem i bundler

bundle

(you need to have Redis installed)

On ubuntu you can install redis by:

apt-get install redis-server

Run:

bundle exec rackup

Usage:

Open <http://localhost:4567>

Then from your console:

redis-cli publish message hello

Voila', you shoul see your message in every browser window you have open.

About

Sinatra example using EventSource (Server Sent Events)

Resources

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.