Browse Source

Merge remote-tracking branch 'origin/master'

release/3.x.x
Christian 4 years ago
parent
commit
74e952bb03
1 changed files with 10 additions and 10 deletions
  1. +10
    -10
      Source/MQTTnet/Client/MqttClient.cs

+ 10
- 10
Source/MQTTnet/Client/MqttClient.cs View File

@@ -142,14 +142,17 @@ namespace MQTTnet.Client


ThrowIfDisposed(); ThrowIfDisposed();


var disconnectIsPending = DisconnectIsPending();
if (DisconnectIsPending())
{
return;
}


try try
{ {
_disconnectReason = MqttClientDisconnectReason.NormalDisconnection; _disconnectReason = MqttClientDisconnectReason.NormalDisconnection;
_cleanDisconnectInitiated = true; _cleanDisconnectInitiated = true;


if (!disconnectIsPending && _isConnected)
if (_isConnected)
{ {
var disconnectPacket = _adapter.PacketFormatterAdapter.DataConverter.CreateDisconnectPacket(options); var disconnectPacket = _adapter.PacketFormatterAdapter.DataConverter.CreateDisconnectPacket(options);
await SendAsync(disconnectPacket, cancellationToken).ConfigureAwait(false); await SendAsync(disconnectPacket, cancellationToken).ConfigureAwait(false);
@@ -157,10 +160,7 @@ namespace MQTTnet.Client
} }
finally finally
{ {
if (!disconnectIsPending)
{
await DisconnectInternalAsync(null, null, null).ConfigureAwait(false);
}
await DisconnectInternalAsync(null, null, null).ConfigureAwait(false);
} }
} }


@@ -225,7 +225,7 @@ namespace MQTTnet.Client


ThrowIfDisposed(); ThrowIfDisposed();
ThrowIfNotConnected(); ThrowIfNotConnected();
var publishPacket = _adapter.PacketFormatterAdapter.DataConverter.CreatePublishPacket(applicationMessage); var publishPacket = _adapter.PacketFormatterAdapter.DataConverter.CreatePublishPacket(applicationMessage);


switch (applicationMessage.QualityOfServiceLevel) switch (applicationMessage.QualityOfServiceLevel)
@@ -312,7 +312,7 @@ namespace MQTTnet.Client
async Task DisconnectInternalAsync(Task sender, Exception exception, MqttClientAuthenticateResult authenticateResult) async Task DisconnectInternalAsync(Task sender, Exception exception, MqttClientAuthenticateResult authenticateResult)
{ {
var clientWasConnected = _isConnected; var clientWasConnected = _isConnected;
TryInitiateDisconnect(); TryInitiateDisconnect();
_isConnected = false; _isConnected = false;


@@ -572,7 +572,7 @@ namespace MQTTnet.Client


if (!DisconnectIsPending()) if (!DisconnectIsPending())
{ {
await DisconnectInternalAsync(_packetReceiverTask, null, null);
await DisconnectInternalAsync(_packetReceiverTask, null, null).ConfigureAwait(false);
} }
} }
else if (packet is MqttAuthPacket authPacket) else if (packet is MqttAuthPacket authPacket)
@@ -634,7 +634,7 @@ namespace MQTTnet.Client
{ {
try try
{ {
var publishPacketDequeueResult = await _publishPacketReceiverQueue.TryDequeueAsync(cancellationToken);
var publishPacketDequeueResult = await _publishPacketReceiverQueue.TryDequeueAsync(cancellationToken).ConfigureAwait(false);
if (!publishPacketDequeueResult.IsSuccess) if (!publishPacketDequeueResult.IsSuccess)
{ {
return; return;


Loading…
Cancel
Save