Browse Source

Remove obsolete methods.

release/3.x.x
Christian Kratky 5 years ago
parent
commit
d0f1659eec
3 changed files with 7 additions and 53 deletions
  1. +0
    -19
      Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs
  2. +0
    -29
      Source/MQTTnet/Implementations/MqttTcpChannel.cs
  3. +7
    -5
      Source/MQTTnet/Server/MqttClientConnection.cs

+ 0
- 19
Source/MQTTnet/Client/Options/MqttClientOptionsBuilder.cs View File

@@ -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)


+ 0
- 29
Source/MQTTnet/Implementations/MqttTcpChannel.cs View File

@@ -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<X509Certificate, X509Chain, SslPolicyErrors, MqttClientTcpOptions, bool> 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<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

+ 7
- 5
Source/MQTTnet/Server/MqttClientConnection.cs View File

@@ -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;
}


Loading…
Cancel
Save