fix: remove callback tcs on response
This commit is contained in:
parent
de672241f7
commit
d8d4510d0f
|
@ -236,12 +236,16 @@ public abstract class ClientNode : Node
|
||||||
{
|
{
|
||||||
if (packet is null) throw new ArgumentNullException(nameof(packet));
|
if (packet is null) throw new ArgumentNullException(nameof(packet));
|
||||||
|
|
||||||
|
long callbackId = packet.CallbackId;
|
||||||
var completionSource = new TaskCompletionSource<ResponsePacket>();
|
var completionSource = new TaskCompletionSource<ResponsePacket>();
|
||||||
if (!_callbackCompletionSources.TryAdd(packet.CallbackId, completionSource))
|
|
||||||
|
if (!_callbackCompletionSources.TryAdd(callbackId, completionSource))
|
||||||
throw new InvalidOperationException("Duplicate packet sent");
|
throw new InvalidOperationException("Duplicate packet sent");
|
||||||
|
|
||||||
await SendPacketAsync(packet, cancellationToken);
|
await SendPacketAsync(packet, cancellationToken);
|
||||||
return (TReceive)await completionSource.Task;
|
var response = (TReceive)await completionSource.Task;
|
||||||
|
_callbackCompletionSources.TryRemove(callbackId, out _);
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue