Interface ISseEventStreamWriter
- Namespace
- ModelContextProtocol.Server
- Assembly
- ModelContextProtocol.Core.dll
Provides write access to an SSE event stream, allowing events to be written and tracked with unique IDs.
public interface ISseEventStreamWriter : IAsyncDisposable
- Inherited Members
Methods
SetModeAsync(SseEventStreamMode, CancellationToken)
Sets the mode of the event stream.
ValueTask SetModeAsync(SseEventStreamMode mode, CancellationToken cancellationToken = default)
Parameters
modeSseEventStreamModeThe new mode to set for the event stream.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- ValueTask
A task that represents the asynchronous operation.
WriteEventAsync(SseItem<JsonRpcMessage?>, CancellationToken)
Writes an event to the stream.
ValueTask<SseItem<JsonRpcMessage?>> WriteEventAsync(SseItem<JsonRpcMessage?> sseItem, CancellationToken cancellationToken = default)
Parameters
sseItemSseItem<JsonRpcMessage>The original System.Net.ServerSentEvents.SseItem<T>.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- ValueTask<SseItem<JsonRpcMessage>>
A new System.Net.ServerSentEvents.SseItem<T> with a populated event ID.
Remarks
If the provided sseItem already has an event ID, this method skips writing the event.
Otherwise, an event ID unique to all sessions and streams is generated and assigned to the event.