mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-19 19:13:11 +08:00
Remove obsolete methods.
This commit is contained in:
@@ -169,25 +169,6 @@ namespace MQTTnet.Client.Options
|
|||||||
return WithTls(new MqttClientOptionsBuilderTlsParameters { UseTls = true });
|
return WithTls(new MqttClientOptionsBuilderTlsParameters { UseTls = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("Use method _WithTls_ which accepts the _MqttClientOptionsBuilderTlsParameters_.")]
|
|
||||||
public MqttClientOptionsBuilder WithTls(
|
|
||||||
bool allowUntrustedCertificates = false,
|
|
||||||
bool ignoreCertificateChainErrors = false,
|
|
||||||
bool ignoreCertificateRevocationErrors = false,
|
|
||||||
params byte[][] certificates)
|
|
||||||
{
|
|
||||||
_tlsParameters = new MqttClientOptionsBuilderTlsParameters
|
|
||||||
{
|
|
||||||
UseTls = true,
|
|
||||||
AllowUntrustedCertificates = allowUntrustedCertificates,
|
|
||||||
IgnoreCertificateChainErrors = ignoreCertificateChainErrors,
|
|
||||||
IgnoreCertificateRevocationErrors = ignoreCertificateRevocationErrors,
|
|
||||||
Certificates = certificates?.ToList()
|
|
||||||
};
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IMqttClientOptions Build()
|
public IMqttClientOptions Build()
|
||||||
{
|
{
|
||||||
if (_tcpOptions == null && _webSocketOptions == null)
|
if (_tcpOptions == null && _webSocketOptions == null)
|
||||||
|
|||||||
@@ -44,9 +44,6 @@ namespace MQTTnet.Implementations
|
|||||||
CreateStream(sslStream);
|
CreateStream(sslStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("There is a new callback at the TLS options. This one will be deleted soon.")]
|
|
||||||
public static Func<X509Certificate, X509Chain, SslPolicyErrors, MqttClientTcpOptions, bool> CustomCertificateValidationCallback { get; set; }
|
|
||||||
|
|
||||||
public string Endpoint => _socket?.RemoteEndPoint?.ToString();
|
public string Endpoint => _socket?.RemoteEndPoint?.ToString();
|
||||||
|
|
||||||
public bool IsSecureConnection { get; }
|
public bool IsSecureConnection { get; }
|
||||||
@@ -134,18 +131,11 @@ namespace MQTTnet.Implementations
|
|||||||
|
|
||||||
private bool InternalUserCertificateValidationCallback(object sender, X509Certificate x509Certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
|
private bool InternalUserCertificateValidationCallback(object sender, X509Certificate x509Certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
|
||||||
{
|
{
|
||||||
// Try the instance callback.
|
|
||||||
if (_options.TlsOptions.CertificateValidationCallback != null)
|
if (_options.TlsOptions.CertificateValidationCallback != null)
|
||||||
{
|
{
|
||||||
return _options.TlsOptions.CertificateValidationCallback(x509Certificate, chain, sslPolicyErrors, _clientOptions);
|
return _options.TlsOptions.CertificateValidationCallback(x509Certificate, chain, sslPolicyErrors, _clientOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try static callback.
|
|
||||||
if (CustomCertificateValidationCallback != null)
|
|
||||||
{
|
|
||||||
return CustomCertificateValidationCallback(x509Certificate, chain, sslPolicyErrors, _options);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sslPolicyErrors == SslPolicyErrors.None)
|
if (sslPolicyErrors == SslPolicyErrors.None)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -197,25 +187,6 @@ namespace MQTTnet.Implementations
|
|||||||
_stream = new NetworkStream(_socket, true);
|
_stream = new NetworkStream(_socket, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Cleanup<T>(ref T item, Action<T> handler) where T : class
|
|
||||||
{
|
|
||||||
var temp = item;
|
|
||||||
item = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (temp != null)
|
|
||||||
{
|
|
||||||
handler(temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ObjectDisposedException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
catch (NullReferenceException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -138,7 +138,9 @@ namespace MQTTnet.Server
|
|||||||
|
|
||||||
Session.WillMessage = _connectPacket.WillMessage;
|
Session.WillMessage = _connectPacket.WillMessage;
|
||||||
|
|
||||||
Task.Run(() => SendPendingPacketsAsync(), _cancellationToken.Token);
|
#pragma warning disable 4014
|
||||||
|
Task.Run(() => SendPendingPacketsAsync(_cancellationToken.Token), _cancellationToken.Token);
|
||||||
|
#pragma warning restore 4014
|
||||||
|
|
||||||
// TODO: Change to single thread in SessionManager. Or use SessionManager and stats from KeepAliveMonitor.
|
// TODO: Change to single thread in SessionManager. Or use SessionManager and stats from KeepAliveMonitor.
|
||||||
_keepAliveMonitor.Start(_connectPacket.KeepAlivePeriod, _cancellationToken.Token);
|
_keepAliveMonitor.Start(_connectPacket.KeepAlivePeriod, _cancellationToken.Token);
|
||||||
@@ -372,22 +374,22 @@ namespace MQTTnet.Server
|
|||||||
//await Task.FromResult(0);
|
//await Task.FromResult(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SendPendingPacketsAsync()
|
private async Task SendPendingPacketsAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
MqttPendingApplicationMessage queuedApplicationMessage = null;
|
MqttPendingApplicationMessage queuedApplicationMessage = null;
|
||||||
MqttPublishPacket publishPacket = null;
|
MqttPublishPacket publishPacket = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while (!_cancellationToken.IsCancellationRequested)
|
while (!cancellationToken.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
queuedApplicationMessage = await Session.ApplicationMessagesQueue.TakeAsync(_cancellationToken.Token).ConfigureAwait(false);
|
queuedApplicationMessage = await Session.ApplicationMessagesQueue.TakeAsync(cancellationToken).ConfigureAwait(false);
|
||||||
if (queuedApplicationMessage == null)
|
if (queuedApplicationMessage == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cancellationToken.IsCancellationRequested)
|
if (cancellationToken.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user