From d3848d8cb0d3760cadbff8fcabdf1445dd9f65ad Mon Sep 17 00:00:00 2001 From: Christian <6939810+chkr1011@users.noreply.github.com> Date: Sat, 23 Jul 2022 11:00:21 +0200 Subject: [PATCH] Add comments. --- .github/workflows/ReleaseNotes.md | 3 ++- .../WebSocket4NetMqttChannel.cs | 1 - .../Client/Options/MqttClientOptionsBuilder.cs | 3 +-- .../MQTTnet/Client/Options/MqttClientTcpOptions.cs | 5 +++++ .../Client/Options/MqttClientWebSocketOptions.cs | 14 +++++++------- .../Options/MqttClientWebSocketProxyOptions.cs | 2 +- .../Implementations/MqttWebSocketChannel.cs | 1 - 7 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ReleaseNotes.md b/.github/workflows/ReleaseNotes.md index 897cf698..e1b28022 100644 --- a/.github/workflows/ReleaseNotes.md +++ b/.github/workflows/ReleaseNotes.md @@ -5,4 +5,5 @@ * [Server] Fixed reporting of _MaximumQoS_ in _ConnAck_ packet (MQTTv5 only) (#1442). * [Server] Fix cross thread issue in session message storage for QoS 1 and 2. * [Server] The event _ClientSubscribedTopicAsync_ is now fired after the subscription is completely processed internally (#1435). -* [Server] Improved CPU usage on lower end machines (#788). \ No newline at end of file +* [Server] Improved CPU usage on lower end machines (#788). +* [Client] Added support for passing the local endpoint which should be used (network card). \ No newline at end of file diff --git a/Source/MQTTnet.Extensions.WebSocket4Net/WebSocket4NetMqttChannel.cs b/Source/MQTTnet.Extensions.WebSocket4Net/WebSocket4NetMqttChannel.cs index c628f542..47e78eec 100644 --- a/Source/MQTTnet.Extensions.WebSocket4Net/WebSocket4NetMqttChannel.cs +++ b/Source/MQTTnet.Extensions.WebSocket4Net/WebSocket4NetMqttChannel.cs @@ -98,7 +98,6 @@ namespace MQTTnet.Extensions.WebSocket4Net #else certificates.Add(certificate); #endif - } } diff --git a/Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs b/Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs index d8568770..7e3d2547 100644 --- a/Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs +++ b/Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs @@ -264,8 +264,7 @@ namespace MQTTnet.Client return this; } - - // TODO: Consider creating _MqttClientTcpOptionsBuilder_ as overload. + public MqttClientOptionsBuilder WithTcpServer(Action optionsBuilder) { if (optionsBuilder == null) diff --git a/Source/MQTTnet/Client/Options/MqttClientTcpOptions.cs b/Source/MQTTnet/Client/Options/MqttClientTcpOptions.cs index 879d8ac7..586cab51 100644 --- a/Source/MQTTnet/Client/Options/MqttClientTcpOptions.cs +++ b/Source/MQTTnet/Client/Options/MqttClientTcpOptions.cs @@ -19,6 +19,11 @@ namespace MQTTnet.Client public int BufferSize { get; set; } = 8192; + /// + /// Gets or sets whether the underlying socket should run in dual mode. + /// Leaving this _null_ will avoid setting this value at socket level. + /// Setting this a value other than _null_ will throw an exception when only IPv4 is supported on the machine. + /// public bool? DualMode { get; set; } public LingerOption LingerState { get; set; } = new LingerOption(true, 0); diff --git a/Source/MQTTnet/Client/Options/MqttClientWebSocketOptions.cs b/Source/MQTTnet/Client/Options/MqttClientWebSocketOptions.cs index 03160a86..e9de2da8 100644 --- a/Source/MQTTnet/Client/Options/MqttClientWebSocketOptions.cs +++ b/Source/MQTTnet/Client/Options/MqttClientWebSocketOptions.cs @@ -7,23 +7,23 @@ using System.Net; namespace MQTTnet.Client { - public class MqttClientWebSocketOptions : IMqttClientChannelOptions + public sealed class MqttClientWebSocketOptions : IMqttClientChannelOptions { - public string Uri { get; set; } + public CookieContainer CookieContainer { get; set; } + + public MqttClientWebSocketProxyOptions ProxyOptions { get; set; } public IDictionary RequestHeaders { get; set; } public ICollection SubProtocols { get; set; } = new List { "mqtt" }; - public CookieContainer CookieContainer { get; set; } - - public MqttClientWebSocketProxyOptions ProxyOptions { get; set; } - public MqttClientTlsOptions TlsOptions { get; set; } = new MqttClientTlsOptions(); + + public string Uri { get; set; } public override string ToString() { return Uri; } } -} +} \ No newline at end of file diff --git a/Source/MQTTnet/Client/Options/MqttClientWebSocketProxyOptions.cs b/Source/MQTTnet/Client/Options/MqttClientWebSocketProxyOptions.cs index 17a6e2de..92968984 100644 --- a/Source/MQTTnet/Client/Options/MqttClientWebSocketProxyOptions.cs +++ b/Source/MQTTnet/Client/Options/MqttClientWebSocketProxyOptions.cs @@ -4,7 +4,7 @@ namespace MQTTnet.Client { - public class MqttClientWebSocketProxyOptions + public sealed class MqttClientWebSocketProxyOptions { public string Address { get; set; } diff --git a/Source/MQTTnet/Implementations/MqttWebSocketChannel.cs b/Source/MQTTnet/Implementations/MqttWebSocketChannel.cs index 7a3b4a9f..3a54843d 100644 --- a/Source/MQTTnet/Implementations/MqttWebSocketChannel.cs +++ b/Source/MQTTnet/Implementations/MqttWebSocketChannel.cs @@ -118,7 +118,6 @@ namespace MQTTnet.Implementations void SetupClientWebSocket(ClientWebSocket clientWebSocket) { - if (_options.ProxyOptions != null) { clientWebSocket.Options.Proxy = CreateProxy();