mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-25 23:53:07 +08:00
Refactor code.
This commit is contained in:
@@ -36,7 +36,7 @@ namespace MQTTnet.Tests
|
||||
public async Task Connect_To_Invalid_Server_Port_Not_Opened()
|
||||
{
|
||||
var client = new MqttFactory().CreateMqttClient();
|
||||
await client.ConnectAsync(new MqttClientOptionsBuilder().WithTcpServer("127.0.0.1", 12345).WithCommunicationTimeout(TimeSpan.FromSeconds(2)).Build());
|
||||
await client.ConnectAsync(new MqttClientOptionsBuilder().WithTcpServer("127.0.0.1", 12345).WithCommunicationTimeout(TimeSpan.FromSeconds(5)).Build());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -115,7 +115,13 @@ namespace MQTTnet.Tests
|
||||
}
|
||||
});
|
||||
|
||||
client2.UseApplicationMessageReceivedHandler(async c => { await client2.PublishAsync("reply", null, MqttQualityOfServiceLevel.AtLeastOnce); });
|
||||
client2.UseApplicationMessageReceivedHandler(async c =>
|
||||
{
|
||||
// Use AtMostOnce here because with QoS 1 or even QoS 2 the process waits for
|
||||
// the ACK etc. The problem is that the SpinUntil below only waits until the
|
||||
// flag is set. It does not wait until the client has sent the ACK
|
||||
await client2.PublishAsync("reply", null, MqttQualityOfServiceLevel.AtMostOnce);
|
||||
});
|
||||
|
||||
await client1.PublishAsync("request", null, MqttQualityOfServiceLevel.AtLeastOnce);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user