Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 2 KB

README.md

File metadata and controls

48 lines (34 loc) · 2 KB

Rails 4 ActionController::Live and HTML5 Server Sent Events

Using Browser feature SSE to retrieve changes on a Rails4 application stream

Removing HTTP/2 Server Push from Chrome

Steps

  1. rails 4.0.0 new
  2. Add Puma server, witch support Server Sent Events: http://puma.io/
  3. Allow concurrency on development enviroment
  4. Add helper to write on stream
  5. Scaffold a model to use on live test
  6. Add stream capability to UsersController, using ActionController::Live
  7. Provide stream, of last user changed, on UsersController and consumes using HTML5 Server Sent Event

How to see it working

Easy way

  1. Deploy
  2. heroku run rake db:migrate

Local way

  1. git clone https://github.com/acdesouza/rails-and-server-sent-events.git .
  2. bundle install
  3. bundle exec rake db:create db:migrate
  4. bundle exec rails s

And then...

  1. On Browser 1: User watch stream
  2. On Browser 2: User watch stream
  3. On Browser 3: User list
  4. Redimension browser's windows to make browser visible
  5. On Browser 3: Create an user
  6. On Browser 1,2: See they receiving the update

Fonts