Skip to content

Commit

Permalink
Warnings cleanup and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pglombardo committed Oct 5, 2023
1 parent 270516b commit 5acd046
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 73 deletions.
4 changes: 0 additions & 4 deletions Source/HiveMQtt/Client/Events/BeforeDisconnectEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@
*/
namespace HiveMQtt.Client.Events;

using HiveMQtt.Client.Options;

/// <summary>
/// Event arguments for the <see cref="HiveMQClient.BeforeDisconnect"/> event.
/// <para>This event is called before a disconnect is sent to the broker.</para>
/// <para><see cref="BeforeDisconnectEventArgs.Options"/> contains the options of the disconnect operation.</para>
/// </summary>
public class BeforeDisconnectEventArgs : EventArgs
{
public BeforeDisconnectEventArgs()
{
}

public HiveMQClientOptions Options { get; set; }
}
6 changes: 3 additions & 3 deletions Source/HiveMQtt/Client/HiveMQClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace HiveMQtt.Client;
/// </summary>
public partial class HiveMQClient : IDisposable, IHiveMQClient
{
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();

private ConnectState connectState = ConnectState.Disconnected;

Expand Down Expand Up @@ -289,7 +289,7 @@ public async Task<SubscribeResult> SubscribeAsync(SubscribeOptions options)

// FIXME: Validate that the packet identifier matches
}
catch (System.TimeoutException ex)
catch (TimeoutException ex)
{
// log.Error(string.Format("Connect timeout. No response received in time.", ex);
throw ex;
Expand Down Expand Up @@ -363,7 +363,7 @@ public async Task<UnsubscribeResult> UnsubscribeAsync(List<Subscription> subscri

// FIXME: Validate that the packet identifier matches
}
catch (System.TimeoutException)
catch (TimeoutException)
{
// log.Error(string.Format("Connect timeout. No response received in time.", ex);
throw;
Expand Down
58 changes: 29 additions & 29 deletions Source/HiveMQtt/Client/HiveMQClientEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public partial class HiveMQClient : IDisposable, IHiveMQClient
protected virtual void BeforeConnectEventLauncher(HiveMQClientOptions options)
{
var eventArgs = new BeforeConnectEventArgs(options);
logger.Trace("BeforeConnectEventLauncher");
Logger.Trace("BeforeConnectEventLauncher");
this.BeforeConnect?.Invoke(this, eventArgs);
}

Expand All @@ -50,7 +50,7 @@ protected virtual void BeforeConnectEventLauncher(HiveMQClientOptions options)
protected virtual void AfterConnectEventLauncher(ConnectResult results)
{
var eventArgs = new AfterConnectEventArgs(results);
logger.Trace("AfterConnectEventLauncher");
Logger.Trace("AfterConnectEventLauncher");
this.AfterConnect?.Invoke(this, eventArgs);
}

Expand All @@ -62,7 +62,7 @@ protected virtual void AfterConnectEventLauncher(ConnectResult results)
protected virtual void BeforeDisconnectEventLauncher()
{
var eventArgs = new BeforeDisconnectEventArgs();
logger.Trace("BeforeDisconnectEventLauncher");
Logger.Trace("BeforeDisconnectEventLauncher");
this.BeforeDisconnect?.Invoke(this, eventArgs);
}

Expand All @@ -74,7 +74,7 @@ protected virtual void BeforeDisconnectEventLauncher()
protected virtual void AfterDisconnectEventLauncher(bool clean = false)
{
var eventArgs = new AfterDisconnectEventArgs(clean);
logger.Trace("AfterDisconnectEventLauncher");
Logger.Trace("AfterDisconnectEventLauncher");
this.AfterDisconnect?.Invoke(this, eventArgs);
}

Expand All @@ -86,7 +86,7 @@ protected virtual void AfterDisconnectEventLauncher(bool clean = false)
protected virtual void BeforeSubscribeEventLauncher(SubscribeOptions options)
{
var eventArgs = new BeforeSubscribeEventArgs(options);
logger.Trace("BeforeSubscribeEventLauncher");
Logger.Trace("BeforeSubscribeEventLauncher");
this.BeforeSubscribe?.Invoke(this, eventArgs);
}

Expand All @@ -98,7 +98,7 @@ protected virtual void BeforeSubscribeEventLauncher(SubscribeOptions options)
protected virtual void AfterSubscribeEventLauncher(SubscribeResult results)
{
var eventArgs = new AfterSubscribeEventArgs(results);
logger.Trace("AfterSubscribeEventLauncher");
Logger.Trace("AfterSubscribeEventLauncher");
this.AfterSubscribe?.Invoke(this, eventArgs);
}

Expand All @@ -110,7 +110,7 @@ protected virtual void AfterSubscribeEventLauncher(SubscribeResult results)
protected virtual void BeforeUnsubscribeEventLauncher(List<Subscription> subscriptions)
{
var eventArgs = new BeforeUnsubscribeEventArgs(subscriptions);
logger.Trace("BeforeUnsubscribeEventLauncher");
Logger.Trace("BeforeUnsubscribeEventLauncher");
this.BeforeUnsubscribe?.Invoke(this, eventArgs);
}

Expand All @@ -122,7 +122,7 @@ protected virtual void BeforeUnsubscribeEventLauncher(List<Subscription> subscri
protected virtual void AfterUnsubscribeEventLauncher(UnsubscribeResult results)
{
var eventArgs = new AfterUnsubscribeEventArgs(results);
logger.Trace("AfterUnsubscribeEventLauncher");
Logger.Trace("AfterUnsubscribeEventLauncher");
this.AfterUnsubscribe?.Invoke(this, eventArgs);
}

Expand All @@ -134,7 +134,7 @@ protected virtual void AfterUnsubscribeEventLauncher(UnsubscribeResult results)
protected virtual void OnMessageReceivedEventLauncher(PublishPacket packet)
{
var eventArgs = new OnMessageReceivedEventArgs(packet.Message);
logger.Trace("OnMessageReceivedEventLauncher");
Logger.Trace("OnMessageReceivedEventLauncher");
this.OnMessageReceived?.Invoke(this, eventArgs);
}

Expand All @@ -150,7 +150,7 @@ protected virtual void OnMessageReceivedEventLauncher(PublishPacket packet)
protected virtual void OnConnectSentEventLauncher(ConnectPacket packet)
{
var eventArgs = new OnConnectSentEventArgs(packet);
logger.Trace("OnConnectSentEventLauncher");
Logger.Trace("OnConnectSentEventLauncher");
this.OnConnectSent?.Invoke(this, eventArgs);
}

Expand All @@ -162,7 +162,7 @@ protected virtual void OnConnectSentEventLauncher(ConnectPacket packet)
protected virtual void OnConnAckReceivedEventLauncher(ConnAckPacket packet)
{
var eventArgs = new OnConnAckReceivedEventArgs(packet);
logger.Trace("OnConnAckReceivedEventLauncher");
Logger.Trace("OnConnAckReceivedEventLauncher");
this.OnConnAckReceived?.Invoke(this, eventArgs);
}

Expand All @@ -174,7 +174,7 @@ protected virtual void OnConnAckReceivedEventLauncher(ConnAckPacket packet)
protected virtual void OnDisconnectSentEventLauncher(DisconnectPacket packet)
{
var eventArgs = new OnDisconnectSentEventArgs(packet);
logger.Trace("OnDisconnectSentEventLauncher");
Logger.Trace("OnDisconnectSentEventLauncher");
this.OnDisconnectSent?.Invoke(this, eventArgs);
}

Expand All @@ -186,7 +186,7 @@ protected virtual void OnDisconnectSentEventLauncher(DisconnectPacket packet)
protected virtual void OnDisconnectReceivedEventLauncher(DisconnectPacket packet)
{
var eventArgs = new OnDisconnectReceivedEventArgs(packet);
logger.Trace("OnDisconnectReceivedEventLauncher: ReasonCode: " + packet.DisconnectReasonCode + " ReasonString: " + packet.Properties.ReasonString);
Logger.Trace("OnDisconnectReceivedEventLauncher: ReasonCode: " + packet.DisconnectReasonCode + " ReasonString: " + packet.Properties.ReasonString);
this.OnDisconnectReceived?.Invoke(this, eventArgs);
}

Expand All @@ -198,7 +198,7 @@ protected virtual void OnDisconnectReceivedEventLauncher(DisconnectPacket packet
protected virtual void OnPingReqSentEventLauncher(PingReqPacket packet)
{
var eventArgs = new OnPingReqSentEventArgs(packet);
logger.Trace("OnPingReqSentEventLauncher");
Logger.Trace("OnPingReqSentEventLauncher");
this.OnPingReqSent?.Invoke(this, eventArgs);
}

Expand All @@ -210,7 +210,7 @@ protected virtual void OnPingReqSentEventLauncher(PingReqPacket packet)
protected virtual void OnPingRespReceivedEventLauncher(PingRespPacket packet)
{
var eventArgs = new OnPingRespReceivedEventArgs(packet);
logger.Trace("OnPingRespReceivedEventLauncher");
Logger.Trace("OnPingRespReceivedEventLauncher");
this.OnPingRespReceived?.Invoke(this, eventArgs);
}

Expand All @@ -222,7 +222,7 @@ protected virtual void OnPingRespReceivedEventLauncher(PingRespPacket packet)
protected virtual void OnSubscribeSentEventLauncher(SubscribePacket packet)
{
var eventArgs = new OnSubscribeSentEventArgs(packet);
logger.Trace("OnSubscribeSentEventLauncher");
Logger.Trace("OnSubscribeSentEventLauncher");
this.OnSubscribeSent?.Invoke(this, eventArgs);
}

Expand All @@ -234,7 +234,7 @@ protected virtual void OnSubscribeSentEventLauncher(SubscribePacket packet)
protected virtual void OnSubAckReceivedEventLauncher(SubAckPacket packet)
{
var eventArgs = new OnSubAckReceivedEventArgs(packet);
logger.Trace("OnSubAckReceivedEventLauncher");
Logger.Trace("OnSubAckReceivedEventLauncher");
this.OnSubAckReceived?.Invoke(this, eventArgs);
}

Expand All @@ -246,7 +246,7 @@ protected virtual void OnSubAckReceivedEventLauncher(SubAckPacket packet)
protected virtual void OnUnsubscribeSentEventLauncher(UnsubscribePacket packet)
{
var eventArgs = new OnUnsubscribeSentEventArgs(packet);
logger.Trace("OnUnsubscribeSentEventLauncher");
Logger.Trace("OnUnsubscribeSentEventLauncher");
this.OnUnsubscribeSent?.Invoke(this, eventArgs);
}

Expand All @@ -258,7 +258,7 @@ protected virtual void OnUnsubscribeSentEventLauncher(UnsubscribePacket packet)
protected virtual void OnUnsubAckReceivedEventLauncher(UnsubAckPacket packet)
{
var eventArgs = new OnUnsubAckReceivedEventArgs(packet);
logger.Trace("OnUnsubAckReceivedEventLauncher");
Logger.Trace("OnUnsubAckReceivedEventLauncher");
this.OnUnsubAckReceived?.Invoke(this, eventArgs);
}

Expand All @@ -270,7 +270,7 @@ protected virtual void OnUnsubAckReceivedEventLauncher(UnsubAckPacket packet)
protected virtual void OnPublishReceivedEventLauncher(PublishPacket packet)
{
var eventArgs = new OnPublishReceivedEventArgs(packet);
logger.Trace("OnPublishReceivedEventLauncher");
Logger.Trace("OnPublishReceivedEventLauncher");
this.OnPublishReceived?.Invoke(this, eventArgs);
}

Expand All @@ -282,7 +282,7 @@ protected virtual void OnPublishReceivedEventLauncher(PublishPacket packet)
protected virtual void OnPublishSentEventLauncher(PublishPacket packet)
{
var eventArgs = new OnPublishSentEventArgs(packet);
logger.Trace("OnPublishSentEventLauncher");
Logger.Trace("OnPublishSentEventLauncher");
this.OnPublishSent?.Invoke(this, eventArgs);
}

Expand All @@ -294,7 +294,7 @@ protected virtual void OnPublishSentEventLauncher(PublishPacket packet)
protected virtual void OnPubAckReceivedEventLauncher(PubAckPacket packet)
{
var eventArgs = new OnPubAckReceivedEventArgs(packet);
logger.Trace("OnPubAckReceivedEventLauncher");
Logger.Trace("OnPubAckReceivedEventLauncher");
this.OnPubAckReceived?.Invoke(this, eventArgs);
}

Expand All @@ -306,7 +306,7 @@ protected virtual void OnPubAckReceivedEventLauncher(PubAckPacket packet)
protected virtual void OnPubAckSentEventLauncher(PubAckPacket packet)
{
var eventArgs = new OnPubAckSentEventArgs(packet);
logger.Trace("OnPubAckSentEventLauncher");
Logger.Trace("OnPubAckSentEventLauncher");
this.OnPubAckSent?.Invoke(this, eventArgs);
}

Expand All @@ -318,7 +318,7 @@ protected virtual void OnPubAckSentEventLauncher(PubAckPacket packet)
protected virtual void OnPubRecReceivedEventLauncher(PubRecPacket packet)
{
var eventArgs = new OnPubRecReceivedEventArgs(packet);
logger.Trace("OnPubRecReceivedEventLauncher");
Logger.Trace("OnPubRecReceivedEventLauncher");
this.OnPubRecReceived?.Invoke(this, eventArgs);
}

Expand All @@ -330,7 +330,7 @@ protected virtual void OnPubRecReceivedEventLauncher(PubRecPacket packet)
protected virtual void OnPubRecSentEventLauncher(PubRecPacket packet)
{
var eventArgs = new OnPubRecSentEventArgs(packet);
logger.Trace("OnPubRecSentEventLauncher");
Logger.Trace("OnPubRecSentEventLauncher");
this.OnPubRecSent?.Invoke(this, eventArgs);
}

Expand All @@ -342,7 +342,7 @@ protected virtual void OnPubRecSentEventLauncher(PubRecPacket packet)
protected virtual void OnPubRelReceivedEventLauncher(PubRelPacket packet)
{
var eventArgs = new OnPubRelReceivedEventArgs(packet);
logger.Trace("OnPubRelReceivedEventLauncher");
Logger.Trace("OnPubRelReceivedEventLauncher");
this.OnPubRelReceived?.Invoke(this, eventArgs);
}

Expand All @@ -354,7 +354,7 @@ protected virtual void OnPubRelReceivedEventLauncher(PubRelPacket packet)
protected virtual void OnPubRelSentEventLauncher(PubRelPacket packet)
{
var eventArgs = new OnPubRelSentEventArgs(packet);
logger.Trace("OnPubRelSentEventLauncher");
Logger.Trace("OnPubRelSentEventLauncher");
this.OnPubRelSent?.Invoke(this, eventArgs);
}

Expand All @@ -366,7 +366,7 @@ protected virtual void OnPubRelSentEventLauncher(PubRelPacket packet)
protected virtual void OnPubCompReceivedEventLauncher(PubCompPacket packet)
{
var eventArgs = new OnPubCompReceivedEventArgs(packet);
logger.Trace("PubCompReceivedEventLauncher");
Logger.Trace("PubCompReceivedEventLauncher");
this.OnPubCompReceived?.Invoke(this, eventArgs);
}

Expand All @@ -378,7 +378,7 @@ protected virtual void OnPubCompReceivedEventLauncher(PubCompPacket packet)
protected virtual void OnPubCompSentEventLauncher(PubCompPacket packet)
{
var eventArgs = new OnPubCompSentEventArgs(packet);
logger.Trace("PubCompSentEventLauncher");
Logger.Trace("PubCompSentEventLauncher");
this.OnPubCompSent?.Invoke(this, eventArgs);
}
}
2 changes: 1 addition & 1 deletion Source/HiveMQtt/Client/HiveMQClientSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ internal async Task<bool> ConnectSocketAsync()
_ = this.TrafficOutflowProcessorAsync(this.outFlowCancellationToken);
_ = this.TrafficInflowProcessorAsync(this.infoFlowCancellationToken);

logger.Trace($"Socket connected to {this.socket.RemoteEndPoint}");
Logger.Trace($"Socket connected to {this.socket.RemoteEndPoint}");
return socketConnected;
}

Expand Down
Loading

0 comments on commit 5acd046

Please sign in to comment.