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(String); call flush() when the stream ends. Not thread-safe — each connection should use its own instance.

  • Constructor Details

  • Method Details

    • processLineTooLong

      public void processLineTooLong()
      Signals that the transport layer detected a line exceeding the configured limit before materialising the full line in memory. This marks the current event block as corrupt (same as if processLine(String) had received an oversized string) and reports the error, without requiring the caller to allocate a placeholder string.
    • 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.