Package org.a2aproject.sdk.client.http
Class ServerSentEventParser
java.lang.Object
org.a2aproject.sdk.client.http.ServerSentEventParser
Streaming parser for Server-Sent Events (SSE).
Feed lines one at a time via processLine(java.lang.String); call flush() when the stream ends.
Not thread-safe — each connection should use its own instance.
-
Constructor Summary
ConstructorsConstructorDescriptionServerSentEventParser(Consumer<ServerSentEvent> eventConsumer) ServerSentEventParser(Consumer<ServerSentEvent> eventConsumer, @Nullable Consumer<Throwable> errorConsumer) -
Method Summary
Modifier and TypeMethodDescriptionvoidflush()Dispatches any buffered data not yet followed by an empty line.@Nullable StringReturns the last event ID received, ornullif none.@Nullable LonggetRetry()Returns the reconnection interval in milliseconds from the lastretry:field, ornullif none.voidprocessLine(@Nullable String line) Processes a single line from the SSE stream.
-
Constructor Details
-
ServerSentEventParser
-
ServerSentEventParser
public ServerSentEventParser(Consumer<ServerSentEvent> eventConsumer, @Nullable Consumer<Throwable> errorConsumer)
-
-
Method Details
-
processLine
Processes a single line from the SSE stream. An empty line dispatches any buffered event. Anullline is routed to the error consumer (or logged) without affecting the current event block. -
flush
public void flush()Dispatches any buffered data not yet followed by an empty line. Call when the stream ends. -
getLastEventId
Returns the last event ID received, ornullif none. -
getRetry
Returns the reconnection interval in milliseconds from the lastretry:field, ornullif none.
-