Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Source/HiveMQtt/Client/HiveMQClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,22 @@

// Setup the task completion source to wait for the SUBACK
var taskCompletionSource = new TaskCompletionSource<SubAckPacket>();
void TaskHandler(object? sender, OnSubAckReceivedEventArgs args) => taskCompletionSource.SetResult(args.SubAckPacket);
void TaskHandler(object? sender, OnSubAckReceivedEventArgs args)
{
if (args.SubAckPacket.PacketIdentifier == subscribePacket.PacketIdentifier)
{
taskCompletionSource.SetResult(args.SubAckPacket);
}
}

EventHandler<OnSubAckReceivedEventArgs> eventHandler = TaskHandler;
this.OnSubAckReceived += eventHandler;

// Queue the constructed packet to be sent on the wire
this.Connection.SendQueue.Enqueue(subscribePacket);

Check warning on line 332 in Source/HiveMQtt/Client/HiveMQClient.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-6.0.x

Code should not contain multiple blank lines in a row

Check warning on line 332 in Source/HiveMQtt/Client/HiveMQClient.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-6.0.x

Code should not contain multiple blank lines in a row

Check warning on line 332 in Source/HiveMQtt/Client/HiveMQClient.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-7.0.x

Check warning on line 332 in Source/HiveMQtt/Client/HiveMQClient.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-7.0.x

Check warning on line 332 in Source/HiveMQtt/Client/HiveMQClient.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-7.0.x

Check warning on line 332 in Source/HiveMQtt/Client/HiveMQClient.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-8.0.x

Check warning on line 332 in Source/HiveMQtt/Client/HiveMQClient.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-8.0.x

Check warning on line 332 in Source/HiveMQtt/Client/HiveMQClient.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-9.0.x

Check warning on line 332 in Source/HiveMQtt/Client/HiveMQClient.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-9.0.x

Check warning on line 332 in Source/HiveMQtt/Client/HiveMQClient.cs

View workflow job for this annotation

GitHub Actions / pipeline-ubuntu-latest-dotnet-9.0.x



SubAckPacket subAck;
SubscribeResult subscribeResult;
try
Expand Down Expand Up @@ -423,7 +432,14 @@
var unsubscribePacket = new UnsubscribePacket(unsubOptions, (ushort)packetIdentifier);

var taskCompletionSource = new TaskCompletionSource<UnsubAckPacket>();
void TaskHandler(object? sender, OnUnsubAckReceivedEventArgs args) => taskCompletionSource.SetResult(args.UnsubAckPacket);
void TaskHandler(object? sender, OnUnsubAckReceivedEventArgs args)
{
if (args.UnsubAckPacket.PacketIdentifier == unsubscribePacket.PacketIdentifier)
{
taskCompletionSource.SetResult(args.UnsubAckPacket);
}
}

EventHandler<OnUnsubAckReceivedEventArgs> eventHandler = TaskHandler;
this.OnUnsubAckReceived += eventHandler;

Expand Down
Loading