Pārlūkot izejas kodu

Disallow to call MqttClient.ConnectAsync while Disconnect is pending.

Fix #996
Fix #1010
release/3.x.x
SilverFox pirms 3 gadiem
vecāks
revīzija
c39da42ef2
1 mainītis faili ar 4 papildinājumiem un 1 dzēšanām
  1. +4
    -1
      Source/MQTTnet/Client/MqttClient.cs

+ 4
- 1
Source/MQTTnet/Client/MqttClient.cs Parādīt failu

@@ -71,6 +71,9 @@ namespace MQTTnet.Client

ThrowIfDisposed();

if (Volatile.Read(ref _isDisconnectPending) != 0)
throw new InvalidOperationException("Not allowed to connect while disconnect is pending.");

MqttClientAuthenticateResult authenticateResult = null;

try
@@ -83,7 +86,6 @@ namespace MQTTnet.Client
_backgroundCancellationTokenSource = new CancellationTokenSource();
var backgroundCancellationToken = _backgroundCancellationTokenSource.Token;

_isDisconnectPending = 0;
var adapter = _adapterFactory.CreateClientAdapter(options);
_adapter = adapter;

@@ -357,6 +359,7 @@ namespace MQTTnet.Client
{
Cleanup();
_cleanDisconnectInitiated = false;
Volatile.Write(ref _isDisconnectPending, 0);

_logger.Info("Disconnected.");



Notiek ielāde…
Atcelt
Saglabāt