MqttRpcClient now adds ResponseTopic to MqttApplicationMessage when using MQTT v5 (#1295)

* MqttRpcClient now adds ResponseTopic to MqttApplicationMessage when using MQTT v5

* No need for conditional protocol check (ResponseTopic property won't be added by PacketFormatter in <MQTT v5)

* Cleanup: Remove using
This commit is contained in:
Michi
2021-11-28 12:41:56 +01:00
committed by GitHub
parent 2d94abdde3
commit 25ddfc83a8
2 changed files with 100 additions and 6 deletions
@@ -1,4 +1,4 @@
using MQTTnet.Client;
using MQTTnet.Client;
using MQTTnet.Exceptions;
using MQTTnet.Extensions.Rpc.Options;
using MQTTnet.Extensions.Rpc.Options.TopicGeneration;
@@ -90,6 +90,7 @@ namespace MQTTnet.Extensions.Rpc
.WithTopic(requestTopic)
.WithPayload(payload)
.WithQualityOfServiceLevel(qualityOfServiceLevel)
.WithResponseTopic(responseTopic)
.Build();
try
@@ -99,7 +100,7 @@ namespace MQTTnet.Extensions.Rpc
#else
var awaitable = new TaskCompletionSource<byte[]>(TaskCreationOptions.RunContinuationsAsynchronously);
#endif
if (!_waitingCalls.TryAdd(responseTopic, awaitable))
{
throw new InvalidOperationException();