mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-20 19:58:57 +08:00
Merge branch 'master' into feature/Single_Connection_Monitoring_Task
This commit is contained in:
@@ -3,14 +3,16 @@ using MQTTnet.Client.Connecting;
|
||||
|
||||
namespace MQTTnet.Client.Disconnecting
|
||||
{
|
||||
public class MqttClientDisconnectedEventArgs : EventArgs
|
||||
public sealed class MqttClientDisconnectedEventArgs : EventArgs
|
||||
{
|
||||
public MqttClientDisconnectedEventArgs(bool clientWasConnected, Exception exception, MqttClientAuthenticateResult authenticateResult, MqttClientDisconnectReason reasonCode)
|
||||
public MqttClientDisconnectedEventArgs(bool clientWasConnected, Exception exception, MqttClientAuthenticateResult authenticateResult, MqttClientDisconnectReason reason)
|
||||
{
|
||||
ClientWasConnected = clientWasConnected;
|
||||
Exception = exception;
|
||||
AuthenticateResult = authenticateResult;
|
||||
ReasonCode = reasonCode;
|
||||
Reason = reason;
|
||||
|
||||
ReasonCode = reason;
|
||||
}
|
||||
|
||||
public bool ClientWasConnected { get; }
|
||||
@@ -19,6 +21,9 @@ namespace MQTTnet.Client.Disconnecting
|
||||
|
||||
public MqttClientAuthenticateResult AuthenticateResult { get; }
|
||||
|
||||
public MqttClientDisconnectReason ReasonCode { get; set; } = MqttClientDisconnectReason.NormalDisconnection;
|
||||
public MqttClientDisconnectReason Reason { get; set; }
|
||||
|
||||
[Obsolete("Please use 'Reason' instead. This property will be removed in the future!")]
|
||||
public MqttClientDisconnectReason ReasonCode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,11 @@ namespace MQTTnet.Client.Options
|
||||
|
||||
public Func<MqttClientCertificateValidationCallbackContext, bool> CertificateValidationHandler { get; set; }
|
||||
|
||||
#if NETCOREAPP3_1 || NET5_0
|
||||
public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls13;
|
||||
#else
|
||||
public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12;
|
||||
#endif
|
||||
|
||||
#if WINDOWS_UWP
|
||||
public IEnumerable<IEnumerable<byte>> Certificates { get; set; }
|
||||
|
||||
@@ -26,7 +26,11 @@ namespace MQTTnet.Client.Options
|
||||
public List<SslApplicationProtocol> ApplicationProtocols { get; set; }
|
||||
#endif
|
||||
|
||||
#if NETCOREAPP3_1 || NET5_0
|
||||
public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls13;
|
||||
#else
|
||||
public SslProtocols SslProtocol { get; set; } = SslProtocols.Tls12;
|
||||
#endif
|
||||
|
||||
[Obsolete("This property will be removed soon. Use CertificateValidationHandler instead.")]
|
||||
public Func<X509Certificate, X509Chain, SslPolicyErrors, IMqttClientOptions, bool> CertificateValidationCallback { get; set; }
|
||||
|
||||
@@ -75,11 +75,23 @@ namespace MQTTnet.Implementations
|
||||
_socket.Control.IgnorableServerCertificateErrors.Add(ignorableChainValidationResult);
|
||||
}
|
||||
|
||||
#if NETCOREAPP3_1 || NET5_0
|
||||
var socketProtectionLevel = SocketProtectionLevel.Tls13;
|
||||
if (_options.TlsOptions.SslProtocol == SslProtocols.Tls12)
|
||||
{
|
||||
socketProtectionLevel = SocketProtectionLevel.Tls12;
|
||||
}
|
||||
else if (_options.TlsOptions.SslProtocol == SslProtocols.Tls11)
|
||||
{
|
||||
socketProtectionLevel = SocketProtectionLevel.Tls11;
|
||||
}
|
||||
#else
|
||||
var socketProtectionLevel = SocketProtectionLevel.Tls12;
|
||||
if (_options.TlsOptions.SslProtocol == SslProtocols.Tls11)
|
||||
{
|
||||
socketProtectionLevel = SocketProtectionLevel.Tls11;
|
||||
}
|
||||
#endif
|
||||
else if (_options.TlsOptions.SslProtocol == SslProtocols.Tls)
|
||||
{
|
||||
socketProtectionLevel = SocketProtectionLevel.Tls10;
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace MQTTnet.Implementations
|
||||
ApplicationProtocols = _options.TlsOptions.ApplicationProtocols,
|
||||
ClientCertificates = LoadCertificates(),
|
||||
EnabledSslProtocols = _options.TlsOptions.SslProtocol,
|
||||
CertificateRevocationCheckMode = _options.TlsOptions.IgnoreCertificateRevocationErrors ? X509RevocationMode.Online : X509RevocationMode.NoCheck,
|
||||
CertificateRevocationCheckMode = _options.TlsOptions.IgnoreCertificateRevocationErrors ? X509RevocationMode.NoCheck : X509RevocationMode.Online,
|
||||
TargetHost = _options.Server
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -103,6 +104,16 @@ namespace MQTTnet
|
||||
return this;
|
||||
}
|
||||
|
||||
public MqttApplicationMessageBuilder WithQualityOfServiceLevel(int qualityOfServiceLevel)
|
||||
{
|
||||
if (qualityOfServiceLevel < 0 || qualityOfServiceLevel > 2)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(qualityOfServiceLevel));
|
||||
}
|
||||
|
||||
return WithQualityOfServiceLevel((MqttQualityOfServiceLevel)qualityOfServiceLevel);
|
||||
}
|
||||
|
||||
public MqttApplicationMessageBuilder WithRetainFlag(bool value = true)
|
||||
{
|
||||
_retain = value;
|
||||
|
||||
Reference in New Issue
Block a user