Quellcode durchsuchen

Merge pull request #422 from ifit/client-cancel-task

Client cancel task
release/3.x.x
Christian vor 6 Jahren
committed by GitHub
Ursprung
Commit
0367ad31f1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 9 neuen und 5 gelöschten Zeilen
  1. +4
    -4
      Source/MQTTnet/Client/MqttClient.cs
  2. +5
    -1
      Source/MQTTnet/Server/MqttClientSession.cs

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

@@ -183,10 +183,12 @@ namespace MQTTnet.Client

public void Dispose()
{
_cancellationTokenSource?.Cancel (false);
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = null;

_adapter?.Dispose();
_adapter = null;
}

private async Task<MqttConnAckPacket> AuthenticateAsync(MqttApplicationMessage willApplicationMessage, CancellationToken cancellationToken)
@@ -245,10 +247,7 @@ namespace MQTTnet.Client
}
finally
{
_adapter?.Dispose();
_adapter = null;
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = null;
Dispose ();
_cleanDisconnectInitiated = false;

_logger.Info("Disconnected.");
@@ -394,6 +393,7 @@ namespace MQTTnet.Client

if (exception is OperationCanceledException)
{
_logger.Verbose ("MQTT OperationCanceled exception while receiving packets.");
}
else if (exception is MqttCommunicationException)
{


+ 5
- 1
Source/MQTTnet/Server/MqttClientSession.cs Datei anzeigen

@@ -138,7 +138,9 @@ namespace MQTTnet.Server

_cleanupHandle?.Dispose();
_cleanupHandle = null;

_adapter = null;
_cancellationTokenSource?.Cancel(false);
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = null;
}
@@ -290,7 +292,9 @@ namespace MQTTnet.Server
{
_pendingPacketsQueue?.Dispose();

_cancellationTokenSource?.Cancel ();
_cancellationTokenSource?.Dispose();
_cancellationTokenSource = null;
}

private void ProcessReceivedPacket(IMqttChannelAdapter adapter, MqttBasePacket packet, CancellationToken cancellationToken)


Laden…
Abbrechen
Speichern