Class: Sinatra::SSE::Stream
- Inherits:
-
Object
- Object
- Sinatra::SSE::Stream
- Defined in:
- lib/sinatra/sse.rb
Overview
The SSEStream class wraps a connection as created via the Sinatra stream helper.
Instance Method Summary collapse
-
#callback(&block) ⇒ Object
set a callback block.
- #close ⇒ Object
-
#initialize(out) ⇒ Stream
constructor
:nodoc:.
-
#push(hash) ⇒ Object
Push an event to the client.
Constructor Details
#initialize(out) ⇒ Stream
:nodoc:
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sinatra/sse.rb', line 31 def initialize(out) @out = out @out.callback do cancel_keepalive_timer @callback.call if @callback end reset_keepalive_timer end |
Instance Method Details
#callback(&block) ⇒ Object
set a callback block.
47 48 49 |
# File 'lib/sinatra/sse.rb', line 47 def callback(&block) @callback = Proc.new end |
#close ⇒ Object
42 43 44 |
# File 'lib/sinatra/sse.rb', line 42 def close @out.close end |