diff --git a/Source/MQTTnet.Server/Internal/MqttConnectedClient.cs b/Source/MQTTnet.Server/Internal/MqttConnectedClient.cs index 7bf924af7..bfdb21307 100644 --- a/Source/MQTTnet.Server/Internal/MqttConnectedClient.cs +++ b/Source/MQTTnet.Server/Internal/MqttConnectedClient.cs @@ -62,8 +62,6 @@ public MqttConnectedClient( public string Id => ConnectPacket.ClientId; - public string UserName => ConnectPacket.Username; - public bool IsRunning { get; private set; } public bool IsTakenOver { get; set; } @@ -74,6 +72,8 @@ public MqttConnectedClient( public MqttClientStatistics Statistics { get; } = new(); + public string UserName => ConnectPacket.Username; + public void Dispose() { _cancellationToken?.Dispose(); @@ -219,7 +219,8 @@ async Task HandleIncomingPublishPacket(MqttPublishPacket publishPacket, Cancella var applicationMessage = MqttApplicationMessageFactory.Create(publishPacket); - var dispatchApplicationMessageResult = await _sessionsManager.DispatchApplicationMessage(Id, UserName, Session.Items, applicationMessage, cancellationToken).ConfigureAwait(false); + var dispatchApplicationMessageResult = + await _sessionsManager.DispatchApplicationMessage(Id, UserName, Session.Items, applicationMessage, cancellationToken).ConfigureAwait(false); if (dispatchApplicationMessageResult.CloseConnection) { @@ -230,26 +231,26 @@ async Task HandleIncomingPublishPacket(MqttPublishPacket publishPacket, Cancella switch (publishPacket.QualityOfServiceLevel) { case MqttQualityOfServiceLevel.AtMostOnce: - { - // Do nothing since QoS 0 has no ACK at all! - break; - } + { + // Do nothing since QoS 0 has no ACK at all! + break; + } case MqttQualityOfServiceLevel.AtLeastOnce: - { - var pubAckPacket = MqttPubAckPacketFactory.Create(publishPacket, dispatchApplicationMessageResult); - Session.EnqueueControlPacket(new MqttPacketBusItem(pubAckPacket)); - break; - } + { + var pubAckPacket = MqttPubAckPacketFactory.Create(publishPacket, dispatchApplicationMessageResult); + Session.EnqueueControlPacket(new MqttPacketBusItem(pubAckPacket)); + break; + } case MqttQualityOfServiceLevel.ExactlyOnce: - { - var pubRecPacket = MqttPubRecPacketFactory.Create(publishPacket, dispatchApplicationMessageResult); - Session.EnqueueControlPacket(new MqttPacketBusItem(pubRecPacket)); - break; - } + { + var pubRecPacket = MqttPubRecPacketFactory.Create(publishPacket, dispatchApplicationMessageResult); + Session.EnqueueControlPacket(new MqttPacketBusItem(pubRecPacket)); + break; + } default: - { - throw new MqttCommunicationException("Received a not supported QoS level"); - } + { + throw new MqttCommunicationException("Received a not supported QoS level"); + } } }