Skip to content

makevoid/sinatra_sse_example

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

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

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published