mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-21 04:03:05 +08:00
1546 possible bug in server repeatedly sending the same message to client subscribed with cleansession=false (#1569)
This commit is contained in:
@@ -10,40 +10,36 @@ namespace MQTTnet.Internal
|
||||
{
|
||||
public sealed class MqttPacketBusItem
|
||||
{
|
||||
readonly AsyncTaskCompletionSource<int> _promise = new AsyncTaskCompletionSource<int>();
|
||||
|
||||
readonly AsyncTaskCompletionSource<bool> _promise = new AsyncTaskCompletionSource<bool>();
|
||||
|
||||
public MqttPacketBusItem(MqttPacket packet)
|
||||
{
|
||||
Packet = packet ?? throw new ArgumentNullException(nameof(packet));
|
||||
}
|
||||
|
||||
|
||||
public event EventHandler Completed;
|
||||
|
||||
public MqttPacket Packet { get; }
|
||||
|
||||
public event EventHandler Delivered;
|
||||
|
||||
public Task WaitForDeliveryAsync()
|
||||
{
|
||||
return _promise.Task;
|
||||
}
|
||||
|
||||
public void MarkAsDelivered()
|
||||
{
|
||||
if (_promise.TrySetResult(0))
|
||||
{
|
||||
Delivered?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public void MarkAsFailed(Exception exception)
|
||||
{
|
||||
if (exception == null) throw new ArgumentNullException(nameof(exception));
|
||||
|
||||
_promise.TrySetException(exception);
|
||||
}
|
||||
|
||||
public void MarkAsCancelled()
|
||||
public void Cancel()
|
||||
{
|
||||
_promise.TrySetCanceled();
|
||||
}
|
||||
|
||||
public void Complete()
|
||||
{
|
||||
_promise.TrySetResult(true);
|
||||
Completed?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public void Fail(Exception exception)
|
||||
{
|
||||
_promise.TrySetException(exception);
|
||||
}
|
||||
|
||||
public Task WaitAsync()
|
||||
{
|
||||
return _promise.Task;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user