ソースを参照

Add new options for _MqttClientOptionsBuilder_.

release/3.x.x
Christian Kratky 5年前
コミット
b02f30844c
2個のファイルの変更40行の追加1行の削除
  1. +1
    -0
      Build/MQTTnet.nuspec
  2. +39
    -1
      Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs

+ 1
- 0
Build/MQTTnet.nuspec ファイルの表示

@@ -14,6 +14,7 @@
* [Core] Fixed missing properties from PUBLISH packet in _MqttApplicationMessage_ (thanks to @pcbing).
* [Core] Fixed wrong encoding of PUBREL and PUBCOMP packets for MQTTv5 (thanks to @perphilipp).
* [Client] Added the authentication result to the disconnected handler (only set when connecting failed).
* [Client] Added new overloads for _MqttClientOptionsBuilder_.
* [Server] Fixed a bug which returns wrong flag for existing session in CONNACK packet (thanks to @avengerstark).
* [nuget] .NET Framework builds are now using 4.5.2 or 4.6.1 builds instead of netstandard 2.0.
</releaseNotes>


+ 39
- 1
Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs ファイルの表示

@@ -136,6 +136,16 @@ namespace MQTTnet.Client.Options
return this;
}

public MqttClientOptionsBuilder WithTcpServer(Action<MqttClientTcpOptions> optionsBuilder)
{
if (optionsBuilder == null) throw new ArgumentNullException(nameof(optionsBuilder));

_tcpOptions = new MqttClientTcpOptions();
optionsBuilder.Invoke(_tcpOptions);

return this;
}

public MqttClientOptionsBuilder WithProxy(string address, string username = null, string password = null, string domain = null, bool bypassOnLocal = false, string[] bypassList = null)
{
_proxyOptions = new MqttClientWebSocketProxyOptions
@@ -151,6 +161,15 @@ namespace MQTTnet.Client.Options
return this;
}

public MqttClientOptionsBuilder WithProxy(Action<MqttClientWebSocketProxyOptions> optionsBuilder)
{
if (optionsBuilder == null) throw new ArgumentNullException(nameof(optionsBuilder));

_proxyOptions = new MqttClientWebSocketProxyOptions();
optionsBuilder(_proxyOptions);
return this;
}

public MqttClientOptionsBuilder WithWebSocketServer(string uri, MqttClientOptionsBuilderWebSocketParameters parameters = null)
{
_webSocketOptions = new MqttClientWebSocketOptions
@@ -163,9 +182,19 @@ namespace MQTTnet.Client.Options
return this;
}

public MqttClientOptionsBuilder WithWebSocketServer(Action<MqttClientWebSocketOptions> optionsBuilder)
{
if (optionsBuilder == null) throw new ArgumentNullException(nameof(optionsBuilder));

_webSocketOptions = new MqttClientWebSocketOptions();
optionsBuilder.Invoke(_webSocketOptions);

return this;
}

public MqttClientOptionsBuilder WithTls(MqttClientOptionsBuilderTlsParameters parameters)
{
_tlsParameters = parameters ?? throw new ArgumentNullException(nameof(parameters));
_tlsParameters = parameters;
return this;
}

@@ -174,6 +203,15 @@ namespace MQTTnet.Client.Options
return WithTls(new MqttClientOptionsBuilderTlsParameters { UseTls = true });
}

public MqttClientOptionsBuilder WithTls(Action<MqttClientOptionsBuilderTlsParameters> optionsBuilder)
{
if (optionsBuilder == null) throw new ArgumentNullException(nameof(optionsBuilder));

_tlsParameters = new MqttClientOptionsBuilderTlsParameters();
optionsBuilder(_tlsParameters);
return this;
}

public IMqttClientOptions Build()
{
if (_tcpOptions == null && _webSocketOptions == null)


読み込み中…
キャンセル
保存