mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-18 10:26:11 +08:00
Remove obsolete code.
This commit is contained in:
@@ -142,9 +142,21 @@ namespace MQTTnet.Server.Internal
|
||||
_logger.Info("Client '{0}': Connection stopped.", Id);
|
||||
}
|
||||
|
||||
Task SendPacketAsync(MqttBasePacket packet, CancellationToken cancellationToken)
|
||||
public async Task SendPacketAsync(MqttBasePacket packet, CancellationToken cancellationToken)
|
||||
{
|
||||
return ChannelAdapter.SendPacketAsync(packet, cancellationToken).ContinueWith(task => { Statistics.HandleSentPacket(packet); }, cancellationToken);
|
||||
var interceptingPacketEventArgs = new InterceptingPacketEventArgs
|
||||
{
|
||||
ClientId = Id,
|
||||
Endpoint = Endpoint,
|
||||
Packet = packet,
|
||||
CancellationToken = cancellationToken
|
||||
};
|
||||
|
||||
await _eventContainer.InterceptingOutboundPacketEvent.InvokeAsync(interceptingPacketEventArgs).ConfigureAwait(false);
|
||||
packet = interceptingPacketEventArgs.Packet;
|
||||
|
||||
await ChannelAdapter.SendPacketAsync(packet, cancellationToken).ConfigureAwait(false);
|
||||
Statistics.HandleSentPacket(packet);
|
||||
}
|
||||
|
||||
async Task ReceivePackagesLoop(CancellationToken cancellationToken)
|
||||
|
||||
@@ -42,8 +42,6 @@ namespace MQTTnet.Server.Internal
|
||||
|
||||
public DateTime CreatedTimestamp { get; } = DateTime.UtcNow;
|
||||
|
||||
//public bool IsCleanSession { get; set; } = true;
|
||||
|
||||
public MqttConnectPacket LatestConnectPacket { get; set; }
|
||||
|
||||
public MqttClientSubscriptionsManager SubscriptionsManager { get; }
|
||||
@@ -67,7 +65,6 @@ namespace MQTTnet.Server.Internal
|
||||
{
|
||||
if (_serverOptions.PendingMessagesOverflowStrategy == MqttPendingMessagesOverflowStrategy.DropNewMessage)
|
||||
{
|
||||
// TODO: Log!
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace MQTTnet.Server.Internal
|
||||
var connectionValidatorContext = await ValidateConnection(connectPacket, channelAdapter).ConfigureAwait(false);
|
||||
if (connectionValidatorContext.ReasonCode != MqttConnectReasonCode.Success)
|
||||
{
|
||||
// Send failure response here without preparing a session!
|
||||
// Send failure response here without preparing a connection and session!
|
||||
connAckPacket = _connAckPacketFactory.Create(connectionValidatorContext);
|
||||
await channelAdapter.SendPacketAsync(connAckPacket, cancellationToken).ConfigureAwait(false);
|
||||
return;
|
||||
@@ -105,7 +105,7 @@ namespace MQTTnet.Server.Internal
|
||||
// Pass connAckPacket so that IsSessionPresent flag can be set if the client session already exists
|
||||
clientConnection = await CreateClientConnection(connectPacket, connAckPacket, channelAdapter, connectionValidatorContext.SessionItems).ConfigureAwait(false);
|
||||
|
||||
await channelAdapter.SendPacketAsync(connAckPacket, cancellationToken).ConfigureAwait(false);
|
||||
await clientConnection.SendPacketAsync(connAckPacket, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
await _eventContainer.ClientConnectedEvent.InvokeAsync(() => new MqttServerClientConnectedEventArgs
|
||||
{
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
{
|
||||
public enum MqttApplicationMessageResponseReasonCode
|
||||
{
|
||||
|
||||
Success = 0,
|
||||
//NoMatchingSubscribers = 16,
|
||||
UnspecifiedError = 128,
|
||||
|
||||
@@ -30,12 +30,13 @@ namespace MQTTnet.Server
|
||||
|
||||
public MqttServer(MqttServerOptions options, IEnumerable<IMqttServerAdapter> adapters, IMqttNetLogger logger)
|
||||
{
|
||||
_options = options ?? throw new ArgumentNullException(nameof(options));
|
||||
|
||||
if (adapters == null) throw new ArgumentNullException(nameof(adapters));
|
||||
_adapters = adapters.ToList();
|
||||
|
||||
if (logger == null) throw new ArgumentNullException(nameof(logger));
|
||||
_logger = logger.WithSource(nameof(MqttServer));
|
||||
_options = options;
|
||||
_rootLogger = logger;
|
||||
|
||||
_eventContainer = new MqttServerEventContainer(logger);
|
||||
@@ -71,7 +72,7 @@ namespace MQTTnet.Server
|
||||
remove => _eventContainer.ClientDisconnectedEvent.RemoveHandler(value);
|
||||
}
|
||||
|
||||
public event Func<InterceptingPacketEventArgs, Task> InterceptInboundPacketAsync
|
||||
public event Func<InterceptingPacketEventArgs, Task> InterceptingInboundPacketAsync
|
||||
{
|
||||
add => _eventContainer.InterceptingInboundPacketEvent.AddHandler(value);
|
||||
remove => _eventContainer.InterceptingInboundPacketEvent.RemoveHandler(value);
|
||||
|
||||
@@ -1,51 +1,19 @@
|
||||
using System;
|
||||
using System.Security.Authentication;
|
||||
using System.Security.Authentication;
|
||||
using MQTTnet.Certificates;
|
||||
|
||||
namespace MQTTnet.Server
|
||||
{
|
||||
public class MqttServerTlsTcpEndpointOptions : MqttServerTcpEndpointBaseOptions
|
||||
public sealed class MqttServerTlsTcpEndpointOptions : MqttServerTcpEndpointBaseOptions
|
||||
{
|
||||
ICertificateProvider _certificateProvider;
|
||||
|
||||
public MqttServerTlsTcpEndpointOptions()
|
||||
{
|
||||
Port = 8883;
|
||||
}
|
||||
|
||||
[Obsolete("Please use CertificateProvider with 'BlobCertificateProvider' instead.")]
|
||||
public byte[] Certificate { get; set; }
|
||||
|
||||
[Obsolete("Please use CertificateProvider with 'BlobCertificateProvider' including password property instead.")]
|
||||
public IMqttServerCertificateCredentials CertificateCredentials { get; set; }
|
||||
|
||||
#if !WINDOWS_UWP
|
||||
public System.Net.Security.RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get; set; }
|
||||
#endif
|
||||
public ICertificateProvider CertificateProvider
|
||||
{
|
||||
get
|
||||
{
|
||||
// Backward compatibility only. Gets converted to auto property when
|
||||
// obsolete properties are removed.
|
||||
if (_certificateProvider != null)
|
||||
{
|
||||
return _certificateProvider;
|
||||
}
|
||||
|
||||
if (Certificate == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new BlobCertificateProvider(Certificate)
|
||||
{
|
||||
Password = CertificateCredentials?.Password
|
||||
};
|
||||
}
|
||||
|
||||
set => _certificateProvider = value;
|
||||
}
|
||||
public ICertificateProvider CertificateProvider { get; set; }
|
||||
|
||||
public bool ClientCertificateRequired { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user