Class: Rack::Stream::Handlers::EventSource
- Inherits:
-
AbstractHandler
- Object
- AbstractHandler
- Rack::Stream::Handlers::EventSource
- Defined in:
- lib/rack/stream/handlers/event_source.rb
Overview
Handler to stream to EventSource
Class Method Summary collapse
Instance Method Summary collapse
-
#close ⇒ Object
TODO: browser initiates connection again, isn't closed.
- #open ⇒ Object
Methods inherited from AbstractHandler
Constructor Details
This class inherits a constructor from Rack::Stream::Handlers::AbstractHandler
Class Method Details
.accepts?(app) ⇒ Boolean
6 7 8 |
# File 'lib/rack/stream/handlers/event_source.rb', line 6 def self.accepts?(app) ::Faye::EventSource.eventsource?(app.env) end |
Instance Method Details
#close ⇒ Object
TODO: browser initiates connection again, isn't closed
11 12 13 14 15 |
# File 'lib/rack/stream/handlers/event_source.rb', line 11 def close @body.callback { @es.close } end |
#open ⇒ Object
17 18 19 20 21 22 |
# File 'lib/rack/stream/handlers/event_source.rb', line 17 def open @es = ::Faye::EventSource.new(@app.env) @es.onopen = lambda do |event| @body.each {|c| @es.send(c)} end end |