Package dev.tachyonmcp.core.server
Interface OutboundSseStream
- All Known Implementing Classes:
PostSseStream
Outbound SSE stream bound to the current dispatch context. Allows a handler executing a
JSON-RPC request to lazily upgrade the response transport to a Server-Sent Events stream so
the server can push notifications and requests to the client before the final response.
The stream is dormant until start() is called (typically on the first server-to-client
message issued during dispatch). Once started, subsequent events flow as SSE frames. The final
response is appended as an SSE event by the dispatcher after the handler completes, then the
stream is closed.
Implementations are transport-specific. The Netty implementation (PostSseStream) ties
this to the HTTP POST response channel; other transports may bind it differently.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the SSE stream.default voidWrites an SSE comment line (: message\r\n), upgrading the stream viastart()first if it has not started.voidstart()Activates the SSE stream and emits initial framing.booleanstarted()default @Nullable StringA stable key identifying this stream within its session, used to tag event-log entries and to suffix SSE event ids (<n>#<key>) so aLast-Event-IDcan be correlated back to the originating stream for per-stream replay.voidwriteEvent(@Nullable SseEvent event) Writes an SSE event.
-
Method Details
-
streamKey
A stable key identifying this stream within its session, used to tag event-log entries and to suffix SSE event ids (<n>#<key>) so aLast-Event-IDcan be correlated back to the originating stream for per-stream replay.nullidentifies the session's general-purpose GET stream. -
start
void start()Activates the SSE stream and emits initial framing. Idempotent — subsequent calls are no-ops. May be called from any thread. -
started
boolean started()- Returns:
trueonce the stream has been opened.
-
writeEvent
Writes an SSE event. Ifstart()has not been called yet, the event is buffered and emitted when the stream upgrades. May be called from any thread.- Parameters:
event- the SSE event to write
-
comment
Writes an SSE comment line (: message\r\n), upgrading the stream viastart()first if it has not started. A comment carries no event data — it exists to keep the connection alive without a progress token. Anullor blank message emits a bare:\r\n. May be called from any thread. Default is a no-op for transports that do not support raw comments.- Parameters:
message- comment text (a single line; embedded line breaks are flattened), ornull
-
close
void close()Closes the SSE stream. Idempotent — subsequent calls are no-ops.
-