HttpListener based SSE Server Support (#73)
This commit is contained in:
parent
4597bbd7c2
commit
b5a26e4c33
1 changed files with 1197 additions and 11 deletions
|
|
@ -21,7 +21,7 @@ public sealed class SseClientTransport : TransportBase, IClientTransport
|
|||
private readonly SseClientTransportOptions _options;
|
||||
private readonly Uri _sseEndpoint;
|
||||
private Uri? _messageEndpoint;
|
||||
private readonly CancellationTokenSource _connectionCts;
|
||||
private CancellationTokenSource? _connectionCts;
|
||||
private Task? _receiveTask;
|
||||
private readonly ILogger _logger;
|
||||
private readonly McpServerConfig _serverConfig;
|
||||
|
|
@ -82,7 +82,7 @@ public sealed class SseClientTransport : TransportBase, IClientTransport
|
|||
}
|
||||
|
||||
// Start message receiving loop
|
||||
_receiveTask = ReceiveMessagesAsync(_connectionCts.Token);
|
||||
_receiveTask = ReceiveMessagesAsync(_connectionCts!.Token);
|
||||
|
||||
_logger.TransportReadingMessages(EndpointName);
|
||||
|
||||
|
|
@ -168,7 +168,12 @@ public sealed class SseClientTransport : TransportBase, IClientTransport
|
|||
/// <inheritdoc/>
|
||||
public async Task CloseAsync()
|
||||
{
|
||||
await _connectionCts.CancelAsync().ConfigureAwait(false);
|
||||
if (_connectionCts != null)
|
||||
{
|
||||
await _connectionCts.CancelAsync().ConfigureAwait(false);
|
||||
_connectionCts.Dispose();
|
||||
_connectionCts = null;
|
||||
}
|
||||
if (_receiveTask != null)
|
||||
await _receiveTask.ConfigureAwait(false);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue