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
|
|
@ -82,4 +82,21 @@ public sealed class RequestContext<TParams>
|
|||
/// including the method name, parameters, request ID, and associated transport and user information.
|
||||
/// </remarks>
|
||||
public JsonRpcRequest JsonRpcRequest { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Ends the current response and enables polling for updates from the server.
|
||||
/// </summary>
|
||||
/// <param name="retryInterval">The interval at which the client should poll for updates.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>A <see cref="ValueTask"/> that completes when polling has been enabled.</returns>
|
||||
/// <exception cref="InvalidOperationException">Thrown when the transport does not support polling.</exception>
|
||||
public async ValueTask EnablePollingAsync(TimeSpan retryInterval, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (JsonRpcRequest.Context?.RelatedTransport is not StreamableHttpPostTransport transport)
|
||||
{
|
||||
throw new InvalidOperationException("Polling is only supported for Streamable HTTP transports.");
|
||||
}
|
||||
|
||||
await transport.EnablePollingAsync(retryInterval, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue