mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-16 17:23:04 +08:00
Renamed trace class
This commit is contained in:
@@ -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!)
|
||||
</releaseNotes>
|
||||
<copyright>Copyright Christian Kratky 2016-2017</copyright>
|
||||
<tags>MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M</tags>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,41 +2,41 @@
|
||||
|
||||
namespace MQTTnet.Core.Diagnostics
|
||||
{
|
||||
public static class MqttTrace
|
||||
public static class MqttNetTrace
|
||||
{
|
||||
public static event EventHandler<MqttTraceMessagePublishedEventArgs> TraceMessagePublished;
|
||||
public static event EventHandler<MqttNetTraceMessagePublishedEventArgs> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace MQTTnet.Core.Diagnostics
|
||||
{
|
||||
public enum MqttTraceLevel
|
||||
public enum MqttNetTraceLevel
|
||||
{
|
||||
Verbose,
|
||||
Information,
|
||||
+3
-3
@@ -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; }
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<MqttPublishPacket>(_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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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, () =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user