Module: Transmitter::Origin
- Defined in:
- lib/transmitter/origin.rb
Instance Method Summary collapse
- #close_connection ⇒ Object
- #set_headers ⇒ Object
- #sse ⇒ Object
- #stream ⇒ Object
- #stream_closed? ⇒ Boolean
- #transmit(opts) ⇒ Object
Instance Method Details
#close_connection ⇒ Object
16 17 18 |
# File 'lib/transmitter/origin.rb', line 16 def close_connection sse.close end |
#set_headers ⇒ Object
24 25 26 27 |
# File 'lib/transmitter/origin.rb', line 24 def set_headers return if headers['Content-Type'] == 'text/event-stream' headers['Content-Type'] = 'text/event-stream' end |
#sse ⇒ Object
29 30 31 |
# File 'lib/transmitter/origin.rb', line 29 def sse @sse ||= SSE.new response.stream end |
#stream ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/transmitter/origin.rb', line 3 def stream begin set_headers yield ensure close_connection end end |
#stream_closed? ⇒ Boolean
20 21 22 |
# File 'lib/transmitter/origin.rb', line 20 def stream_closed? response.stream.closed? end |
#transmit(opts) ⇒ Object
12 13 14 |
# File 'lib/transmitter/origin.rb', line 12 def transmit(opts) sse.(opts).stream unless stream_closed? end |