mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-15 00:15:15 +08:00
Avoid using obsolete code
This commit is contained in:
@@ -18,13 +18,13 @@ namespace MQTTnet.Client
|
||||
public sealed class MqttClientOptionsBuilder
|
||||
{
|
||||
readonly MqttClientOptions _options = new MqttClientOptions();
|
||||
int? _port;
|
||||
|
||||
[Obsolete] MqttClientWebSocketProxyOptions _proxyOptions;
|
||||
EndPoint _remoteEndPoint;
|
||||
|
||||
MqttClientTcpOptions _tcpOptions;
|
||||
MqttClientTlsOptions _tlsOptions;
|
||||
EndPoint _remoteEndPoint;
|
||||
int? _port;
|
||||
|
||||
[Obsolete] MqttClientOptionsBuilderTlsParameters _tlsParameters;
|
||||
|
||||
@@ -145,7 +145,6 @@ namespace MQTTnet.Client
|
||||
return this;
|
||||
}
|
||||
|
||||
[Obsolete("Use WithTcpServer(... configure) or WithWebSocketServer(... configure) instead.")]
|
||||
public MqttClientOptionsBuilder WithConnectionUri(Uri uri)
|
||||
{
|
||||
if (uri == null)
|
||||
@@ -158,24 +157,33 @@ namespace MQTTnet.Client
|
||||
{
|
||||
case "tcp":
|
||||
case "mqtt":
|
||||
{
|
||||
WithTcpServer(uri.Host, port);
|
||||
break;
|
||||
}
|
||||
|
||||
case "mqtts":
|
||||
{
|
||||
WithTcpServer(uri.Host, port)
|
||||
.WithTlsOptions(
|
||||
o =>
|
||||
{
|
||||
o.UseTls();
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case "ws":
|
||||
case "wss":
|
||||
{
|
||||
WithWebSocketServer(o => o.WithUri(uri.ToString()));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw new ArgumentException("Unexpected scheme in uri.");
|
||||
{
|
||||
throw new ArgumentException("Unexpected scheme in URI.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(uri.UserInfo))
|
||||
@@ -189,7 +197,6 @@ namespace MQTTnet.Client
|
||||
return this;
|
||||
}
|
||||
|
||||
[Obsolete("Use WithTcpServer(... configure) or WithWebSocketServer(... configure) instead.")]
|
||||
public MqttClientOptionsBuilder WithConnectionUri(string uri)
|
||||
{
|
||||
return WithConnectionUri(new Uri(uri, UriKind.Absolute));
|
||||
@@ -218,6 +225,14 @@ namespace MQTTnet.Client
|
||||
return this;
|
||||
}
|
||||
|
||||
public MqttClientOptionsBuilder WithEndPoint(EndPoint endPoint)
|
||||
{
|
||||
_remoteEndPoint = endPoint ?? throw new ArgumentNullException(nameof(endPoint));
|
||||
_tcpOptions = new MqttClientTcpOptions();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public MqttClientOptionsBuilder WithExtendedAuthenticationExchangeHandler(IMqttExtendedAuthenticationExchangeHandler handler)
|
||||
{
|
||||
_options.ExtendedAuthenticationExchangeHandler = handler;
|
||||
@@ -345,14 +360,6 @@ namespace MQTTnet.Client
|
||||
return this;
|
||||
}
|
||||
|
||||
public MqttClientOptionsBuilder WithEndPoint(EndPoint endPoint)
|
||||
{
|
||||
_remoteEndPoint = endPoint ?? throw new ArgumentNullException(nameof(endPoint));
|
||||
_tcpOptions = new MqttClientTcpOptions();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public MqttClientOptionsBuilder WithTcpServer(Action<MqttClientTcpOptions> optionsBuilder)
|
||||
{
|
||||
if (optionsBuilder == null)
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace MQTTnet.Server
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
TryProcessClients();
|
||||
Sleep(_options.KeepAliveMonitorInterval);
|
||||
Sleep(_options.KeepAliveOptions.MonitorInterval);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
|
||||
Reference in New Issue
Block a user