Pārlūkot izejas kodu

Add overload for subscribing.

release/3.x.x
Christian Kratky pirms 7 gadiem
vecāks
revīzija
fb8b60fccc
2 mainītis faili ar 11 papildinājumiem un 1 dzēšanām
  1. +1
    -0
      Build/MQTTnet.nuspec
  2. +10
    -1
      Frameworks/MQTTnet.NetStandard/ManagedClient/ManagedMqttClientExtensions.cs

+ 1
- 0
Build/MQTTnet.nuspec Parādīt failu

@@ -19,6 +19,7 @@
* [Client] Fixed an issue in _ManagedClient_ which can cause the client to stop when publishing subscriptions.
* [Client] Fixed an issue in _ManagedClient_ which prevents changing the QoS of an existing subscription (BREAKING CHANGE!).
* [Client] Fixed an issue in _MqttClientOptionsBuilder_ which prevents adding TLS options to the client options when calling _Build()_. (Thanks to @cvellan).
* [Client] Added an overload for subscribing at both clients which reduces required code.
* [Server] The application message interceptor can now delete any received application message.
* [Server] Added a ConnectionValidator context to align with other APIs (BREAKING CHANGE! Please find new example in Wiki).
* [Server] Added an interface for the _MqttServerOptions_.


+ 10
- 1
Frameworks/MQTTnet.NetStandard/ManagedClient/ManagedMqttClientExtensions.cs Parādīt failu

@@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
using MQTTnet.Protocol;

namespace MQTTnet.ManagedClient
{
@@ -12,7 +13,15 @@ namespace MQTTnet.ManagedClient
return managedClient.SubscribeAsync(topicFilters);
}

public static Task UnsubscribeAsync(this IManagedMqttClient managedClient, params TopicFilter[] topicFilters)
public static Task SubscribeAsync(this IManagedMqttClient managedClient, string topic, MqttQualityOfServiceLevel qualityOfServiceLevel)
{
if (managedClient == null) throw new ArgumentNullException(nameof(managedClient));
if (topic == null) throw new ArgumentNullException(nameof(topic));

return managedClient.SubscribeAsync(new TopicFilterBuilder().WithTopic(topic).WithQualityOfServiceLevel(qualityOfServiceLevel).Build());
}

public static Task UnsubscribeAsync(this IManagedMqttClient managedClient, params string[] topicFilters)
{
if (managedClient == null) throw new ArgumentNullException(nameof(managedClient));



Notiek ielāde…
Atcelt
Saglabāt