diff --git a/Build/MQTTnet.nuspec b/Build/MQTTnet.nuspec index a20c21bc..fc5d2bd9 100644 --- a/Build/MQTTnet.nuspec +++ b/Build/MQTTnet.nuspec @@ -17,6 +17,8 @@ * [Server] Fixed handling of _Dup_ flag (Thanks to haeberle) * [Core] Optimized exception handling * [Core] Mono is now also supported (Thanks to JTrotta) +* [Client] The options are now passed in _ConnectAsync_ (Breaking change!) +* [Core] Trace class renamed to _MqttNetTrace_ (Breaking change!) Copyright Christian Kratky 2016-2017 MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M diff --git a/Frameworks/MQTTnet.NetFramework/Implementations/MqttServerAdapter.cs b/Frameworks/MQTTnet.NetFramework/Implementations/MqttServerAdapter.cs index 159137cb..c6df6efc 100644 --- a/Frameworks/MQTTnet.NetFramework/Implementations/MqttServerAdapter.cs +++ b/Frameworks/MQTTnet.NetFramework/Implementations/MqttServerAdapter.cs @@ -97,7 +97,7 @@ namespace MQTTnet.Implementations } catch (Exception exception) when (!(exception is ObjectDisposedException)) { - MqttTrace.Error(nameof(MqttServerAdapter), exception, "Error while accepting connection at default endpoint."); + MqttNetTrace.Error(nameof(MqttServerAdapter), exception, "Error while accepting connection at default endpoint."); //excessive CPU consumed if in endless loop of socket errors await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken).ConfigureAwait(false); @@ -122,7 +122,7 @@ namespace MQTTnet.Implementations } catch (Exception exception) { - MqttTrace.Error(nameof(MqttServerAdapter), exception, "Error while accepting connection at TLS endpoint."); + MqttNetTrace.Error(nameof(MqttServerAdapter), exception, "Error while accepting connection at TLS endpoint."); //excessive CPU consumed if in endless loop of socket errors await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken).ConfigureAwait(false); diff --git a/Frameworks/MQTTnet.NetFramework/Implementations/MqttTcpChannel.cs b/Frameworks/MQTTnet.NetFramework/Implementations/MqttTcpChannel.cs index a113ab30..85d9d87a 100644 --- a/Frameworks/MQTTnet.NetFramework/Implementations/MqttTcpChannel.cs +++ b/Frameworks/MQTTnet.NetFramework/Implementations/MqttTcpChannel.cs @@ -56,7 +56,7 @@ namespace MQTTnet.Implementations if (_options.TlsOptions.UseTls) { _sslStream = new SslStream(new NetworkStream(_socket, true)); - + await _sslStream.AuthenticateAsClientAsync(_options.Server, LoadCertificates(_options), SslProtocols.Tls12, _options.TlsOptions.CheckCertificateRevocation).ConfigureAwait(false); } diff --git a/Frameworks/MQTTnet.NetStandard/Implementations/MqttServerAdapter.cs b/Frameworks/MQTTnet.NetStandard/Implementations/MqttServerAdapter.cs index 6a901095..56650dde 100644 --- a/Frameworks/MQTTnet.NetStandard/Implementations/MqttServerAdapter.cs +++ b/Frameworks/MQTTnet.NetStandard/Implementations/MqttServerAdapter.cs @@ -94,7 +94,7 @@ namespace MQTTnet.Implementations } catch (Exception exception) { - MqttTrace.Error(nameof(MqttServerAdapter), exception, "Error while accepting connection at default endpoint."); + MqttNetTrace.Error(nameof(MqttServerAdapter), exception, "Error while accepting connection at default endpoint."); //excessive CPU consumed if in endless loop of socket errors await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken).ConfigureAwait(false); @@ -118,7 +118,7 @@ namespace MQTTnet.Implementations } catch (Exception exception) { - MqttTrace.Error(nameof(MqttServerAdapter), exception, "Error while accepting connection at TLS endpoint."); + MqttNetTrace.Error(nameof(MqttServerAdapter), exception, "Error while accepting connection at TLS endpoint."); //excessive CPU consumed if in endless loop of socket errors await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken).ConfigureAwait(false); diff --git a/Frameworks/MQTTnet.UniversalWindows/Implementations/MqttServerAdapter.cs b/Frameworks/MQTTnet.UniversalWindows/Implementations/MqttServerAdapter.cs index 7206f546..1a742cba 100644 --- a/Frameworks/MQTTnet.UniversalWindows/Implementations/MqttServerAdapter.cs +++ b/Frameworks/MQTTnet.UniversalWindows/Implementations/MqttServerAdapter.cs @@ -61,7 +61,7 @@ namespace MQTTnet.Implementations } catch (Exception exception) { - MqttTrace.Error(nameof(MqttServerAdapter), exception, "Error while accepting connection at default endpoint."); + MqttNetTrace.Error(nameof(MqttServerAdapter), exception, "Error while accepting connection at default endpoint."); } } } diff --git a/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs b/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs index 3ed2ebc6..7fae37b0 100644 --- a/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs +++ b/MQTTnet.Core/Adapter/MqttChannelCommunicationAdapter.cs @@ -4,7 +4,6 @@ using System.IO; using System.Threading; using System.Threading.Tasks; using MQTTnet.Core.Channel; -using MQTTnet.Core.Client; using MQTTnet.Core.Diagnostics; using MQTTnet.Core.Exceptions; using MQTTnet.Core.Internal; @@ -95,7 +94,7 @@ namespace MQTTnet.Core.Adapter continue; } - MqttTrace.Information(nameof(MqttChannelCommunicationAdapter), "TX >>> {0} [Timeout={1}]", packet, timeout); + MqttNetTrace.Information(nameof(MqttChannelCommunicationAdapter), "TX >>> {0} [Timeout={1}]", packet, timeout); var writeBuffer = PacketSerializer.Serialize(packet); await _channel.SendStream.WriteAsync(writeBuffer, 0, writeBuffer.Length, cancellationToken).ConfigureAwait(false); @@ -161,7 +160,7 @@ namespace MQTTnet.Core.Adapter throw new MqttProtocolViolationException("Received malformed packet."); } - MqttTrace.Information(nameof(MqttChannelCommunicationAdapter), "RX <<< {0}", packet); + MqttNetTrace.Information(nameof(MqttChannelCommunicationAdapter), "RX <<< {0}", packet); return packet; } catch (TaskCanceledException) diff --git a/MQTTnet.Core/Client/MqttClient.cs b/MQTTnet.Core/Client/MqttClient.cs index f17800b4..80b850a8 100644 --- a/MQTTnet.Core/Client/MqttClient.cs +++ b/MQTTnet.Core/Client/MqttClient.cs @@ -26,7 +26,7 @@ namespace MQTTnet.Core.Client public MqttClient(IMqttCommunicationAdapterFactory communicationChannelFactory) { - _communicationChannelFactory = communicationChannelFactory; + _communicationChannelFactory = communicationChannelFactory ?? throw new ArgumentNullException(nameof(communicationChannelFactory)); } public event EventHandler Connected; @@ -50,14 +50,14 @@ namespace MQTTnet.Core.Client _adapter = _communicationChannelFactory.CreateMqttCommunicationAdapter(options); - MqttTrace.Verbose(nameof(MqttClient), "Trying to connect with server."); + MqttNetTrace.Verbose(nameof(MqttClient), "Trying to connect with server."); await _adapter.ConnectAsync(_options.DefaultCommunicationTimeout).ConfigureAwait(false); - MqttTrace.Verbose(nameof(MqttClient), "Connection with server established."); + MqttNetTrace.Verbose(nameof(MqttClient), "Connection with server established."); await SetupIncomingPacketProcessingAsync(); await AuthenticateAsync(options.WillMessage); - MqttTrace.Verbose(nameof(MqttClient), "MQTT connection with server established."); + MqttNetTrace.Verbose(nameof(MqttClient), "MQTT connection with server established."); if (_options.KeepAlivePeriod != TimeSpan.Zero) { @@ -235,11 +235,11 @@ namespace MQTTnet.Core.Client try { await _adapter.DisconnectAsync(_options.DefaultCommunicationTimeout).ConfigureAwait(false); - MqttTrace.Information(nameof(MqttClient), "Disconnected from adapter."); + MqttNetTrace.Information(nameof(MqttClient), "Disconnected from adapter."); } catch (Exception exception) { - MqttTrace.Warning(nameof(MqttClient), exception, "Error while disconnecting from adapter."); + MqttNetTrace.Warning(nameof(MqttClient), exception, "Error while disconnecting from adapter."); } finally { @@ -251,7 +251,7 @@ namespace MQTTnet.Core.Client { try { - MqttTrace.Information(nameof(MqttClient), "Received <<< {0}", packet); + MqttNetTrace.Information(nameof(MqttClient), "Received <<< {0}", packet); if (packet is MqttPingReqPacket) { @@ -281,7 +281,7 @@ namespace MQTTnet.Core.Client } catch (Exception exception) { - MqttTrace.Error(nameof(MqttClient), exception, "Unhandled exception while processing received packet."); + MqttNetTrace.Error(nameof(MqttClient), exception, "Unhandled exception while processing received packet."); } } @@ -294,7 +294,7 @@ namespace MQTTnet.Core.Client } catch (Exception exception) { - MqttTrace.Error(nameof(MqttClient), exception, "Unhandled exception while handling application message."); + MqttNetTrace.Error(nameof(MqttClient), exception, "Unhandled exception while handling application message."); } } @@ -358,7 +358,7 @@ namespace MQTTnet.Core.Client private async Task SendKeepAliveMessagesAsync(CancellationToken cancellationToken) { - MqttTrace.Information(nameof(MqttClient), "Start sending keep alive packets."); + MqttNetTrace.Information(nameof(MqttClient), "Start sending keep alive packets."); try { @@ -383,23 +383,23 @@ namespace MQTTnet.Core.Client return; } - MqttTrace.Warning(nameof(MqttClient), exception, "MQTT communication exception while sending/receiving keep alive packets."); + MqttNetTrace.Warning(nameof(MqttClient), exception, "MQTT communication exception while sending/receiving keep alive packets."); await DisconnectInternalAsync().ConfigureAwait(false); } catch (Exception exception) { - MqttTrace.Warning(nameof(MqttClient), exception, "Unhandled exception while sending/receiving keep alive packets."); + MqttNetTrace.Warning(nameof(MqttClient), exception, "Unhandled exception while sending/receiving keep alive packets."); await DisconnectInternalAsync().ConfigureAwait(false); } finally { - MqttTrace.Information(nameof(MqttClient), "Stopped sending keep alive packets."); + MqttNetTrace.Information(nameof(MqttClient), "Stopped sending keep alive packets."); } } private async Task ReceivePackets(CancellationToken cancellationToken) { - MqttTrace.Information(nameof(MqttClient), "Start receiving packets."); + MqttNetTrace.Information(nameof(MqttClient), "Start receiving packets."); try { @@ -426,17 +426,17 @@ namespace MQTTnet.Core.Client return; } - MqttTrace.Warning(nameof(MqttClient), exception, "MQTT communication exception while receiving packets."); + MqttNetTrace.Warning(nameof(MqttClient), exception, "MQTT communication exception while receiving packets."); await DisconnectInternalAsync().ConfigureAwait(false); } catch (Exception exception) { - MqttTrace.Error(nameof(MqttClient), exception, "Unhandled exception while receiving packets."); + MqttNetTrace.Error(nameof(MqttClient), exception, "Unhandled exception while receiving packets."); await DisconnectInternalAsync().ConfigureAwait(false); } finally { - MqttTrace.Information(nameof(MqttClient), "Stopped receiving packets."); + MqttNetTrace.Information(nameof(MqttClient), "Stopped receiving packets."); } } diff --git a/MQTTnet.Core/Client/MqttPacketDispatcher.cs b/MQTTnet.Core/Client/MqttPacketDispatcher.cs index 8f632a26..484012e4 100644 --- a/MQTTnet.Core/Client/MqttPacketDispatcher.cs +++ b/MQTTnet.Core/Client/MqttPacketDispatcher.cs @@ -24,7 +24,7 @@ namespace MQTTnet.Core.Client } catch (MqttCommunicationTimedOutException) { - MqttTrace.Warning(nameof(MqttPacketDispatcher), "Timeout while waiting for packet of type '{0}'.", responseType.Name); + MqttNetTrace.Warning(nameof(MqttPacketDispatcher), "Timeout while waiting for packet of type '{0}'.", responseType.Name); throw; } finally diff --git a/MQTTnet.Core/Diagnostics/MqttTrace.cs b/MQTTnet.Core/Diagnostics/MqttNetTrace.cs similarity index 55% rename from MQTTnet.Core/Diagnostics/MqttTrace.cs rename to MQTTnet.Core/Diagnostics/MqttNetTrace.cs index 5cce5ec9..4ed4619c 100644 --- a/MQTTnet.Core/Diagnostics/MqttTrace.cs +++ b/MQTTnet.Core/Diagnostics/MqttNetTrace.cs @@ -2,41 +2,41 @@ namespace MQTTnet.Core.Diagnostics { - public static class MqttTrace + public static class MqttNetTrace { - public static event EventHandler TraceMessagePublished; + public static event EventHandler TraceMessagePublished; public static void Verbose(string source, string message, params object[] parameters) { - Publish(source, MqttTraceLevel.Verbose, null, message, parameters); + Publish(source, MqttNetTraceLevel.Verbose, null, message, parameters); } public static void Information(string source, string message, params object[] parameters) { - Publish(source, MqttTraceLevel.Information, null, message, parameters); + Publish(source, MqttNetTraceLevel.Information, null, message, parameters); } public static void Warning(string source, string message, params object[] parameters) { - Publish(source, MqttTraceLevel.Warning, null, message, parameters); + Publish(source, MqttNetTraceLevel.Warning, null, message, parameters); } public static void Warning(string source, Exception exception, string message, params object[] parameters) { - Publish(source, MqttTraceLevel.Warning, exception, message, parameters); + Publish(source, MqttNetTraceLevel.Warning, exception, message, parameters); } public static void Error(string source, string message, params object[] parameters) { - Publish(source, MqttTraceLevel.Error, null, message, parameters); + Publish(source, MqttNetTraceLevel.Error, null, message, parameters); } public static void Error(string source, Exception exception, string message, params object[] parameters) { - Publish(source, MqttTraceLevel.Error, exception, message, parameters); + Publish(source, MqttNetTraceLevel.Error, exception, message, parameters); } - private static void Publish(string source, MqttTraceLevel traceLevel, Exception exception, string message, params object[] parameters) + private static void Publish(string source, MqttNetTraceLevel traceLevel, Exception exception, string message, params object[] parameters) { var handler = TraceMessagePublished; if (handler == null) @@ -52,12 +52,12 @@ namespace MQTTnet.Core.Diagnostics } catch (Exception formatException) { - Error(nameof(MqttTrace), formatException, "Error while tracing message: " + message); + Error(nameof(MqttNetTrace), formatException, "Error while tracing message: " + message); return; } } - handler.Invoke(null, new MqttTraceMessagePublishedEventArgs(Environment.CurrentManagedThreadId, source, traceLevel, message, exception)); + handler.Invoke(null, new MqttNetTraceMessagePublishedEventArgs(Environment.CurrentManagedThreadId, source, traceLevel, message, exception)); } } } diff --git a/MQTTnet.Core/Diagnostics/MqttTraceLevel.cs b/MQTTnet.Core/Diagnostics/MqttNetTraceLevel.cs similarity index 78% rename from MQTTnet.Core/Diagnostics/MqttTraceLevel.cs rename to MQTTnet.Core/Diagnostics/MqttNetTraceLevel.cs index 86a0dc1a..5f3a13f4 100644 --- a/MQTTnet.Core/Diagnostics/MqttTraceLevel.cs +++ b/MQTTnet.Core/Diagnostics/MqttNetTraceLevel.cs @@ -1,6 +1,6 @@ namespace MQTTnet.Core.Diagnostics { - public enum MqttTraceLevel + public enum MqttNetTraceLevel { Verbose, Information, diff --git a/MQTTnet.Core/Diagnostics/MqttTraceMessagePublishedEventArgs.cs b/MQTTnet.Core/Diagnostics/MqttNetTraceMessagePublishedEventArgs.cs similarity index 60% rename from MQTTnet.Core/Diagnostics/MqttTraceMessagePublishedEventArgs.cs rename to MQTTnet.Core/Diagnostics/MqttNetTraceMessagePublishedEventArgs.cs index 9ef3dcd6..05d53962 100644 --- a/MQTTnet.Core/Diagnostics/MqttTraceMessagePublishedEventArgs.cs +++ b/MQTTnet.Core/Diagnostics/MqttNetTraceMessagePublishedEventArgs.cs @@ -2,9 +2,9 @@ namespace MQTTnet.Core.Diagnostics { - public sealed class MqttTraceMessagePublishedEventArgs : EventArgs + public sealed class MqttNetTraceMessagePublishedEventArgs : EventArgs { - public MqttTraceMessagePublishedEventArgs(int threadId, string source, MqttTraceLevel level, string message, Exception exception) + public MqttNetTraceMessagePublishedEventArgs(int threadId, string source, MqttNetTraceLevel level, string message, Exception exception) { ThreadId = threadId; Source = source; @@ -17,7 +17,7 @@ namespace MQTTnet.Core.Diagnostics public string Source { get; } - public MqttTraceLevel Level { get; } + public MqttNetTraceLevel Level { get; } public string Message { get; } diff --git a/MQTTnet.Core/Server/MqttClientPendingMessagesQueue.cs b/MQTTnet.Core/Server/MqttClientPendingMessagesQueue.cs index df3aeb06..6571a758 100644 --- a/MQTTnet.Core/Server/MqttClientPendingMessagesQueue.cs +++ b/MQTTnet.Core/Server/MqttClientPendingMessagesQueue.cs @@ -50,7 +50,7 @@ namespace MQTTnet.Core.Server } catch (Exception exception) { - MqttTrace.Error(nameof(MqttClientPendingMessagesQueue), exception, "Unhandled exception while sending pending publish packets."); + MqttNetTrace.Error(nameof(MqttClientPendingMessagesQueue), exception, "Unhandled exception while sending pending publish packets."); } } @@ -66,18 +66,18 @@ namespace MQTTnet.Core.Server { if (exception is MqttCommunicationTimedOutException) { - MqttTrace.Warning(nameof(MqttClientPendingMessagesQueue), exception, "Sending publish packet failed due to timeout."); + MqttNetTrace.Warning(nameof(MqttClientPendingMessagesQueue), exception, "Sending publish packet failed due to timeout."); } else if (exception is MqttCommunicationException) { - MqttTrace.Warning(nameof(MqttClientPendingMessagesQueue), exception, "Sending publish packet failed due to communication exception."); + MqttNetTrace.Warning(nameof(MqttClientPendingMessagesQueue), exception, "Sending publish packet failed due to communication exception."); } if (exception is OperationCanceledException) { } else { - MqttTrace.Error(nameof(MqttClientPendingMessagesQueue), exception, "Sending publish packet failed."); + MqttNetTrace.Error(nameof(MqttClientPendingMessagesQueue), exception, "Sending publish packet failed."); } if (packet.QualityOfServiceLevel > MqttQualityOfServiceLevel.AtMostOnce) diff --git a/MQTTnet.Core/Server/MqttClientRetainedMessagesManager.cs b/MQTTnet.Core/Server/MqttClientRetainedMessagesManager.cs index b12da001..77b49bf7 100644 --- a/MQTTnet.Core/Server/MqttClientRetainedMessagesManager.cs +++ b/MQTTnet.Core/Server/MqttClientRetainedMessagesManager.cs @@ -39,7 +39,7 @@ namespace MQTTnet.Core.Server } catch (Exception exception) { - MqttTrace.Error(nameof(MqttClientRetainedMessagesManager), exception, "Unhandled exception while loading retained messages."); + MqttNetTrace.Error(nameof(MqttClientRetainedMessagesManager), exception, "Unhandled exception while loading retained messages."); } } @@ -53,12 +53,12 @@ namespace MQTTnet.Core.Server if (publishPacket.Payload?.Any() == false) { _retainedMessages.Remove(publishPacket.Topic); - MqttTrace.Information(nameof(MqttClientRetainedMessagesManager), "Client '{0}' cleared retained message for topic '{1}'.", clientId, publishPacket.Topic); + MqttNetTrace.Information(nameof(MqttClientRetainedMessagesManager), "Client '{0}' cleared retained message for topic '{1}'.", clientId, publishPacket.Topic); } else { _retainedMessages[publishPacket.Topic] = publishPacket; - MqttTrace.Information(nameof(MqttClientRetainedMessagesManager), "Client '{0}' updated retained message for topic '{1}'.", clientId, publishPacket.Topic); + MqttNetTrace.Information(nameof(MqttClientRetainedMessagesManager), "Client '{0}' updated retained message for topic '{1}'.", clientId, publishPacket.Topic); } allRetainedMessages = new List(_retainedMessages.Values); @@ -74,7 +74,7 @@ namespace MQTTnet.Core.Server } catch (Exception exception) { - MqttTrace.Error(nameof(MqttClientRetainedMessagesManager), exception, "Unhandled exception while saving retained messages."); + MqttNetTrace.Error(nameof(MqttClientRetainedMessagesManager), exception, "Unhandled exception while saving retained messages."); } } diff --git a/MQTTnet.Core/Server/MqttClientSession.cs b/MQTTnet.Core/Server/MqttClientSession.cs index e94bde00..37d168ae 100644 --- a/MQTTnet.Core/Server/MqttClientSession.cs +++ b/MQTTnet.Core/Server/MqttClientSession.cs @@ -58,11 +58,11 @@ namespace MQTTnet.Core.Server } catch (MqttCommunicationException exception) { - MqttTrace.Warning(nameof(MqttClientSession), exception, "Client '{0}': Communication exception while processing client packets.", ClientId); + MqttNetTrace.Warning(nameof(MqttClientSession), exception, "Client '{0}': Communication exception while processing client packets.", ClientId); } catch (Exception exception) { - MqttTrace.Error(nameof(MqttClientSession), exception, "Client '{0}': Unhandled exception while processing client packets.", ClientId); + MqttNetTrace.Error(nameof(MqttClientSession), exception, "Client '{0}': Unhandled exception while processing client packets.", ClientId); } } @@ -79,7 +79,7 @@ namespace MQTTnet.Core.Server _adapter = null; - MqttTrace.Information(nameof(MqttClientSession), "Client '{0}': Disconnected.", ClientId); + MqttNetTrace.Information(nameof(MqttClientSession), "Client '{0}': Disconnected.", ClientId); } public void EnqueuePublishPacket(MqttPublishPacket publishPacket) @@ -92,7 +92,7 @@ namespace MQTTnet.Core.Server } _pendingMessagesQueue.Enqueue(publishPacket); - MqttTrace.Verbose(nameof(MqttClientSession), "Client '{0}': Enqueued pending publish packet.", ClientId); + MqttNetTrace.Verbose(nameof(MqttClientSession), "Client '{0}': Enqueued pending publish packet.", ClientId); } public void Dispose() @@ -116,12 +116,12 @@ namespace MQTTnet.Core.Server } catch (MqttCommunicationException exception) { - MqttTrace.Warning(nameof(MqttClientSession), exception, "Client '{0}': Communication exception while processing client packets.", ClientId); + MqttNetTrace.Warning(nameof(MqttClientSession), exception, "Client '{0}': Communication exception while processing client packets.", ClientId); Stop(); } catch (Exception exception) { - MqttTrace.Error(nameof(MqttClientSession), exception, "Client '{0}': Unhandled exception while processing client packets.", ClientId); + MqttNetTrace.Error(nameof(MqttClientSession), exception, "Client '{0}': Unhandled exception while processing client packets.", ClientId); Stop(); } } @@ -163,7 +163,7 @@ namespace MQTTnet.Core.Server } else { - MqttTrace.Warning(nameof(MqttClientSession), "Client '{0}': Received not supported packet ({1}). Closing connection.", ClientId, packet); + MqttNetTrace.Warning(nameof(MqttClientSession), "Client '{0}': Received not supported packet ({1}). Closing connection.", ClientId, packet); Stop(); } } diff --git a/MQTTnet.Core/Server/MqttClientSessionsManager.cs b/MQTTnet.Core/Server/MqttClientSessionsManager.cs index df95c7e2..f78a5417 100644 --- a/MQTTnet.Core/Server/MqttClientSessionsManager.cs +++ b/MQTTnet.Core/Server/MqttClientSessionsManager.cs @@ -74,7 +74,7 @@ namespace MQTTnet.Core.Server } catch (Exception exception) { - MqttTrace.Error(nameof(MqttServer), exception, exception.Message); + MqttNetTrace.Error(nameof(MqttServer), exception, exception.Message); } finally { @@ -124,7 +124,7 @@ namespace MQTTnet.Core.Server } catch (Exception exception) { - MqttTrace.Error(nameof(MqttClientSessionsManager), exception, "Error while processing application message"); + MqttNetTrace.Error(nameof(MqttClientSessionsManager), exception, "Error while processing application message"); } lock (_clientSessions) @@ -158,11 +158,11 @@ namespace MQTTnet.Core.Server _clientSessions.Remove(connectPacket.ClientId); clientSession.Dispose(); clientSession = null; - MqttTrace.Verbose(nameof(MqttClientSessionsManager), "Disposed existing session of client '{0}'.", connectPacket.ClientId); + MqttNetTrace.Verbose(nameof(MqttClientSessionsManager), "Disposed existing session of client '{0}'.", connectPacket.ClientId); } else { - MqttTrace.Verbose(nameof(MqttClientSessionsManager), "Reusing existing session of client '{0}'.", connectPacket.ClientId); + MqttNetTrace.Verbose(nameof(MqttClientSessionsManager), "Reusing existing session of client '{0}'.", connectPacket.ClientId); } } @@ -174,7 +174,7 @@ namespace MQTTnet.Core.Server clientSession = new MqttClientSession(connectPacket.ClientId, _options, this); _clientSessions[connectPacket.ClientId] = clientSession; - MqttTrace.Verbose(nameof(MqttClientSessionsManager), "Created a new session for client '{0}'.", connectPacket.ClientId); + MqttNetTrace.Verbose(nameof(MqttClientSessionsManager), "Created a new session for client '{0}'.", connectPacket.ClientId); } return new GetOrCreateClientSessionResult { IsExistingSession = isExistingSession, Session = clientSession }; diff --git a/MQTTnet.Core/Server/MqttServer.cs b/MQTTnet.Core/Server/MqttServer.cs index a2a848f9..2fa72057 100644 --- a/MQTTnet.Core/Server/MqttServer.cs +++ b/MQTTnet.Core/Server/MqttServer.cs @@ -57,7 +57,7 @@ namespace MQTTnet.Core.Server await adapter.StartAsync(_options); } - MqttTrace.Information(nameof(MqttServer), "Started."); + MqttNetTrace.Information(nameof(MqttServer), "Started."); } public async Task StopAsync() @@ -74,7 +74,7 @@ namespace MQTTnet.Core.Server _clientSessionsManager.Clear(); - MqttTrace.Information(nameof(MqttServer), "Stopped."); + MqttNetTrace.Information(nameof(MqttServer), "Stopped."); } private void OnClientAccepted(IMqttCommunicationAdapter adapter) @@ -84,13 +84,13 @@ namespace MQTTnet.Core.Server private void OnClientConnected(object sender, MqttClientConnectedEventArgs eventArgs) { - MqttTrace.Information(nameof(MqttServer), "Client '{0}': Connected.", eventArgs.Client.ClientId); + MqttNetTrace.Information(nameof(MqttServer), "Client '{0}': Connected.", eventArgs.Client.ClientId); ClientConnected?.Invoke(this, eventArgs); } private void OnClientDisconnected(object sender, MqttClientDisconnectedEventArgs eventArgs) { - MqttTrace.Information(nameof(MqttServer), "Client '{0}': Disconnected.", eventArgs.Client.ClientId); + MqttNetTrace.Information(nameof(MqttServer), "Client '{0}': Disconnected.", eventArgs.Client.ClientId); ClientDisconnected?.Invoke(this, eventArgs); } } diff --git a/Tests/MQTTnet.TestApp.NetCore/Program.cs b/Tests/MQTTnet.TestApp.NetCore/Program.cs index 57d2d9a3..0622f7e0 100644 --- a/Tests/MQTTnet.TestApp.NetCore/Program.cs +++ b/Tests/MQTTnet.TestApp.NetCore/Program.cs @@ -35,7 +35,7 @@ namespace MQTTnet.TestApp.NetCore private static async Task RunClientAsync(string[] arguments) { - MqttTrace.TraceMessagePublished += (s, e) => + MqttNetTrace.TraceMessagePublished += (s, e) => { Console.WriteLine($">> [{e.ThreadId}] [{e.Source}] [{e.Level}]: {e.Message}"); if (e.Exception != null) @@ -124,7 +124,7 @@ namespace MQTTnet.TestApp.NetCore private static void RunServerAsync(string[] arguments) { - MqttTrace.TraceMessagePublished += (s, e) => + MqttNetTrace.TraceMessagePublished += (s, e) => { Console.WriteLine($">> [{e.ThreadId}] [{e.Source}] [{e.Level}]: {e.Message}"); if (e.Exception != null) diff --git a/Tests/MQTTnet.TestApp.NetFramework/Program.cs b/Tests/MQTTnet.TestApp.NetFramework/Program.cs index 78cd4067..50867f08 100644 --- a/Tests/MQTTnet.TestApp.NetFramework/Program.cs +++ b/Tests/MQTTnet.TestApp.NetFramework/Program.cs @@ -41,7 +41,7 @@ namespace MQTTnet.TestApp.NetFramework private static async Task RunClientAsync(string[] arguments) { - MqttTrace.TraceMessagePublished += (s, e) => + MqttNetTrace.TraceMessagePublished += (s, e) => { Console.WriteLine($">> [{e.ThreadId}] [{e.Source}] [{e.Level}]: {e.Message}"); if (e.Exception != null) @@ -128,7 +128,7 @@ namespace MQTTnet.TestApp.NetFramework private static async Task RunServerAsync(string[] arguments) { - MqttTrace.TraceMessagePublished += (s, e) => + MqttNetTrace.TraceMessagePublished += (s, e) => { Console.WriteLine($">> [{e.ThreadId}] [{e.Source}] [{e.Level}]: {e.Message}"); if (e.Exception != null) diff --git a/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs b/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs index 8f6c039c..0ad499e2 100644 --- a/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs +++ b/Tests/MQTTnet.TestApp.UniversalWindows/MainPage.xaml.cs @@ -18,10 +18,10 @@ namespace MQTTnet.TestApp.UniversalWindows { InitializeComponent(); - MqttTrace.TraceMessagePublished += OnTraceMessagePublished; + MqttNetTrace.TraceMessagePublished += OnTraceMessagePublished; } - private async void OnTraceMessagePublished(object sender, MqttTraceMessagePublishedEventArgs e) + private async void OnTraceMessagePublished(object sender, MqttNetTraceMessagePublishedEventArgs e) { await Trace.Dispatcher.RunAsync(CoreDispatcherPriority.High, () => {