Class ServerSentEventParser

java.lang.Object
org.a2aproject.sdk.client.http.ServerSentEventParser

public class ServerSentEventParser extends Object
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 Details

  • Method Details

    • processLine

      public void processLine(@Nullable String line)
      Processes a single line from the SSE stream. An empty line dispatches any buffered event. A null line 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

      public @Nullable String getLastEventId()
      Returns the last event ID received, or null if none.
    • getRetry

      public @Nullable Long getRetry()
      Returns the reconnection interval in milliseconds from the last retry: field, or null if none.