diff --git a/Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs b/Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs index e3780c7..ca9c700 100644 --- a/Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs +++ b/Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs @@ -169,25 +169,6 @@ namespace MQTTnet.Client.Options 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() { if (_tcpOptions == null && _webSocketOptions == null) diff --git a/Source/MQTTnet/Implementations/MqttTcpChannel.cs b/Source/MQTTnet/Implementations/MqttTcpChannel.cs index e6b7deb..33d9f18 100644 --- a/Source/MQTTnet/Implementations/MqttTcpChannel.cs +++ b/Source/MQTTnet/Implementations/MqttTcpChannel.cs @@ -44,9 +44,6 @@ namespace MQTTnet.Implementations CreateStream(sslStream); } - [Obsolete("There is a new callback at the TLS options. This one will be deleted soon.")] - public static Func CustomCertificateValidationCallback { get; set; } - public string Endpoint => _socket?.RemoteEndPoint?.ToString(); public bool IsSecureConnection { get; } @@ -134,18 +131,11 @@ namespace MQTTnet.Implementations private bool InternalUserCertificateValidationCallback(object sender, X509Certificate x509Certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { - // Try the instance callback. if (_options.TlsOptions.CertificateValidationCallback != null) { return _options.TlsOptions.CertificateValidationCallback(x509Certificate, chain, sslPolicyErrors, _clientOptions); } - // Try static callback. - if (CustomCertificateValidationCallback != null) - { - return CustomCertificateValidationCallback(x509Certificate, chain, sslPolicyErrors, _options); - } - if (sslPolicyErrors == SslPolicyErrors.None) { return true; @@ -197,25 +187,6 @@ namespace MQTTnet.Implementations _stream = new NetworkStream(_socket, true); } } - - private static void Cleanup(ref T item, Action handler) where T : class - { - var temp = item; - item = null; - try - { - if (temp != null) - { - handler(temp); - } - } - catch (ObjectDisposedException) - { - } - catch (NullReferenceException) - { - } - } } } #endif diff --git a/Source/MQTTnet/Server/MqttClientConnection.cs b/Source/MQTTnet/Server/MqttClientConnection.cs index 4b75ff8..05a10a5 100644 --- a/Source/MQTTnet/Server/MqttClientConnection.cs +++ b/Source/MQTTnet/Server/MqttClientConnection.cs @@ -138,7 +138,9 @@ namespace MQTTnet.Server 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. _keepAliveMonitor.Start(_connectPacket.KeepAlivePeriod, _cancellationToken.Token); @@ -372,22 +374,22 @@ namespace MQTTnet.Server //await Task.FromResult(0); } - private async Task SendPendingPacketsAsync() + private async Task SendPendingPacketsAsync(CancellationToken cancellationToken) { MqttPendingApplicationMessage queuedApplicationMessage = null; MqttPublishPacket publishPacket = null; 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) { return; } - if (_cancellationToken.IsCancellationRequested) + if (cancellationToken.IsCancellationRequested) { return; }