Streamable HTTP resumability + redelivery + SSE polling via server-side disconnect (#1077)
Co-authored-by: Stephen Halter <halter73@gmail.com>
This commit is contained in:
parent
4cb2fd4655
commit
b8311756b4
1 changed files with 2675 additions and 246 deletions
|
|
@ -0,0 +1,36 @@
|
|||
using ModelContextProtocol.Protocol;
|
||||
using System.Net.ServerSentEvents;
|
||||
|
||||
namespace ModelContextProtocol.Server;
|
||||
|
||||
/// <summary>
|
||||
/// Provides read access to an SSE event stream, allowing events to be consumed asynchronously.
|
||||
/// </summary>
|
||||
public interface ISseEventStreamReader
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the session ID associated with the stream being read.
|
||||
/// </summary>
|
||||
string SessionId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ID of the stream.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This value is guaranteed to be unique on a per-session basis.
|
||||
/// </remarks>
|
||||
string StreamId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the messages from the stream as an <see cref="IAsyncEnumerable{T}"/>.
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">A token to cancel the operation.</param>
|
||||
/// <returns>An <see cref="IAsyncEnumerable{T}"/> of <see cref="SseItem{T}"/> containing JSON-RPC messages.</returns>
|
||||
/// <remarks>
|
||||
/// If the stream's mode is set to <see cref="SseEventStreamMode.Polling"/>, the returned
|
||||
/// messages will only include the currently-available events starting at the last event ID specified
|
||||
/// when the reader was created. Otherwise, the returned messages will continue until the associated
|
||||
/// <see cref="ISseEventStreamWriter"/> is disposed.
|
||||
/// </remarks>
|
||||
IAsyncEnumerable<SseItem<JsonRpcMessage?>> ReadEventsAsync(CancellationToken cancellationToken = default);
|
||||
}
|
||||
Loading…
Reference in a new issue