Class: SimpleAcp::Client::SSEStream
- Inherits:
-
Object
- Object
- SimpleAcp::Client::SSEStream
- Includes:
- Enumerable
- Defined in:
- lib/simple_acp/client/sse.rb
Overview
Enumerable wrapper for streaming SSE responses.
Reads from an HTTP response body, parses SSE events, and converts them to ACP event objects.
Instance Method Summary collapse
-
#each {|Models::Event| ... } ⇒ Enumerator
Iterate over ACP events from the stream.
-
#initialize(response) ⇒ SSEStream
constructor
Create a new SSE stream reader.
Constructor Details
Instance Method Details
#each {|Models::Event| ... } ⇒ Enumerator
Iterate over ACP events from the stream.
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/simple_acp/client/sse.rb', line 119 def each return enum_for(:each) unless block_given? @response.body.each do |chunk| @parser.feed(chunk) @parser.each_event do |raw_event| event = parse_acp_event(raw_event) yield event if event end end end |