Quellcode durchsuchen

Updated _ReconnectAsync_ extension methods to retrieve authentication result (#1202)

release/3.x.x
Nikita Senkov vor 3 Jahren
committed by GitHub
Ursprung
Commit
50381637af
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden GPG-Schlüssel-ID: 4AEE18F83AFDEB23
1 geänderte Dateien mit 14 neuen und 2 gelöschten Zeilen
  1. +14
    -2
      Source/MQTTnet/Client/MqttClientExtensions.cs

+ 14
- 2
Source/MQTTnet/Client/MqttClientExtensions.cs Datei anzeigen

@@ -1,4 +1,4 @@
using MQTTnet.Client.Connecting;
using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting;
using MQTTnet.Client.ExtendedAuthenticationExchange;
using MQTTnet.Client.Options;
@@ -112,7 +112,7 @@ namespace MQTTnet.Client
return client;
}

public static Task ReconnectAsync(this IMqttClient client)
public static Task<MqttClientAuthenticateResult> ReconnectAsync(this IMqttClient client)
{
if (client == null) throw new ArgumentNullException(nameof(client));

@@ -124,6 +124,18 @@ namespace MQTTnet.Client
return client.ConnectAsync(client.Options);
}

public static Task<MqttClientAuthenticateResult> ReconnectAsync(this IMqttClient client, CancellationToken cancellationToken)
{
if (client == null) throw new ArgumentNullException(nameof(client));

if (client.Options == null)
{
throw new InvalidOperationException("_ReconnectAsync_ can be used only if _ConnectAsync_ was called before.");
}

return client.ConnectAsync(client.Options, cancellationToken);
}

public static Task DisconnectAsync(this IMqttClient client)
{
if (client == null) throw new ArgumentNullException(nameof(client));


Laden…
Abbrechen
Speichern