Quellcode durchsuchen

Merge pull request #476 from PaulFake/patch-1

Check for pending disconnect in ThrowIfNotConnected
release/3.x.x
Christian vor 6 Jahren
committed by GitHub
Ursprung
Commit
803dd6f64e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden GPG-Schlüssel-ID: 4AEE18F83AFDEB23
1 geänderte Dateien mit 3 neuen und 3 gelöschten Zeilen
  1. +3
    -3
      Source/MQTTnet/Client/MqttClient.cs

+ 3
- 3
Source/MQTTnet/Client/MqttClient.cs Datei anzeigen

@@ -29,7 +29,7 @@ namespace MQTTnet.Client
internal Task _keepAliveMessageSenderTask;
private IMqttChannelAdapter _adapter;
private bool _cleanDisconnectInitiated;
private int _disconnectGate;
private long _disconnectGate;

public MqttClient(IMqttClientAdapterFactory channelFactory, IMqttNetLogger logger)
{
@@ -216,7 +216,7 @@ namespace MQTTnet.Client

private void ThrowIfNotConnected()
{
if (!IsConnected) throw new MqttCommunicationException("The client is not connected.");
if (!IsConnected || Interlocked.Read(ref _disconnectGate) == 1) throw new MqttCommunicationException("The client is not connected.");
}

private void ThrowIfConnected(string message)
@@ -551,4 +551,4 @@ namespace MQTTnet.Client
return Interlocked.CompareExchange(ref _disconnectGate, 1, 0) != 0;
}
}
}
}

Laden…
Abbrechen
Speichern