瀏覽代碼

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

release/3.x.x
Nikita Senkov 3 年之前
committed by GitHub
父節點
當前提交
50381637af
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: 4AEE18F83AFDEB23
共有 1 個文件被更改,包括 14 次插入2 次删除
  1. +14
    -2
      Source/MQTTnet/Client/MqttClientExtensions.cs

+ 14
- 2
Source/MQTTnet/Client/MqttClientExtensions.cs 查看文件

@@ -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));


Loading…
取消
儲存