Class: RubyAPI::SSEStream
- Inherits:
-
Object
- Object
- RubyAPI::SSEStream
- Defined in:
- lib/rubyapi/streaming.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#initialize ⇒ SSEStream
constructor
A new instance of SSEStream.
- #send_event(event:, data:, id: nil) ⇒ Object
Constructor Details
#initialize ⇒ SSEStream
Returns a new instance of SSEStream.
37 38 39 40 41 |
# File 'lib/rubyapi/streaming.rb', line 37 def initialize @body = StreamingBody.new @sse = SSE.new(@body) @closed = false end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
35 36 37 |
# File 'lib/rubyapi/streaming.rb', line 35 def body @body end |
Instance Method Details
#close ⇒ Object
48 49 50 51 52 |
# File 'lib/rubyapi/streaming.rb', line 48 def close @closed = true @sse.close @body.close end |
#send_event(event:, data:, id: nil) ⇒ Object
43 44 45 46 |
# File 'lib/rubyapi/streaming.rb', line 43 def send_event(event:, data:, id: nil) return if @closed @sse.send(event: event, data: data, id: id) end |