Minor refactorings.

This commit is contained in:
Christian Kratky
2020-06-12 11:19:29 +02:00
parent 92518fc4ec
commit 246a10649a
2 changed files with 7 additions and 17 deletions
+3 -9
View File
@@ -57,13 +57,7 @@ namespace MQTTnet.Client
public IMqttApplicationMessageReceivedHandler ApplicationMessageReceivedHandler { get; set; }
public bool IsConnected
{
get
{
return _isConnected && Interlocked.Read(ref _isDisconnectPending) == 0;
}
}
public bool IsConnected => _isConnected && Interlocked.Read(ref _isDisconnectPending) == 0;
public IMqttClientOptions Options { get; private set; }
@@ -164,9 +158,9 @@ namespace MQTTnet.Client
}
}
public async Task PingAsync(CancellationToken cancellationToken)
public Task PingAsync(CancellationToken cancellationToken)
{
await SendAndReceiveAsync<MqttPingRespPacket>(new MqttPingReqPacket(), cancellationToken).ConfigureAwait(false);
return SendAndReceiveAsync<MqttPingRespPacket>(new MqttPingReqPacket(), cancellationToken);
}
public Task SendExtendedAuthenticationExchangeDataAsync(MqttExtendedAuthenticationExchangeData data, CancellationToken cancellationToken)
@@ -14,7 +14,7 @@ using System.Threading.Tasks;
namespace MQTTnet.Server
{
public class MqttClientSessionsManager : Disposable
public sealed class MqttClientSessionsManager : IDisposable
{
readonly AsyncQueue<MqttEnqueuedApplicationMessage> _messageQueue = new AsyncQueue<MqttEnqueuedApplicationMessage>();
@@ -150,13 +150,9 @@ namespace MQTTnet.Server
_logger.Verbose("Session for client '{0}' deleted.", clientId);
}
protected override void Dispose(bool disposing)
public void Dispose()
{
if (disposing)
{
_messageQueue?.Dispose();
}
base.Dispose(disposing);
_messageQueue?.Dispose();
}
async Task TryProcessQueuedApplicationMessagesAsync(CancellationToken cancellationToken)
@@ -245,9 +241,9 @@ namespace MQTTnet.Server
{
string clientId = null;
MqttConnectPacket connectPacket;
try
{
MqttConnectPacket connectPacket;
try
{
var firstPacket = await channelAdapter.ReceivePacketAsync(_options.DefaultCommunicationTimeout, cancellationToken).ConfigureAwait(false);