@@ -1,5 +1,4 @@
#if NET451 || NETSTANDARD1_3
using System;
using System.Net;
using System.Net.Security;
@@ -17,17 +16,17 @@ namespace MQTTnet.Implementations
public class MqttServerAdapter : IMqttServerAdapter, IDisposable
{
private readonly ILogger<MqttServerAdapter> _logger;
private readonly IMqttCommunicationAdapterFactory _mqttC ommunicationAdapterFactory;
private readonly IMqttCommunicationAdapterFactory _c ommunicationAdapterFactory;
private CancellationTokenSource _cancellationTokenSource;
private Socket _defaultEndpointSocket;
private Socket _tlsEndpointSocket;
private X509Certificate2 _tlsCertificate;
public MqttServerAdapter(ILogger<MqttServerAdapter> logger, IMqttCommunicationAdapterFactory mqttC ommunicationAdapterFactory)
public MqttServerAdapter(ILogger<MqttServerAdapter> logger, IMqttCommunicationAdapterFactory c ommunicationAdapterFactory)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_mqttCommunicationAdapterFactory = mqttCommunicationAdapterFactory ?? throw new ArgumentNullException(nameof(mqttC ommunicationAdapterFactory));
_communicationAdapterFactory = communicationAdapterFactory ?? throw new ArgumentNullException(nameof(c ommunicationAdapterFactory));
}
public event EventHandler<MqttServerAdapterClientAcceptedEventArgs> ClientAccepted;
@@ -104,7 +103,7 @@ namespace MQTTnet.Implementations
#else
var clientSocket = await _defaultEndpointSocket.AcceptAsync().ConfigureAwait(false);
#endif
var clientAdapter = _mqttCommunicationAdapterFactory.CreateServerMqtt CommunicationAdapter(new MqttTcpChannel(clientSocket, null));
var clientAdapter = _communicationAdapterFactory.CreateServer CommunicationAdapter(new MqttTcpChannel(clientSocket, null));
ClientAccepted?.Invoke(this, new MqttServerAdapterClientAcceptedEventArgs(clientAdapter));
}
catch (Exception exception)
@@ -132,7 +131,7 @@ namespace MQTTnet.Implementations
var sslStream = new SslStream(new NetworkStream(clientSocket));
await sslStream.AuthenticateAsServerAsync(_tlsCertificate, false, SslProtocols.Tls12, false).ConfigureAwait(false);
var clientAdapter = _mqttCommunicationAdapterFactory.CreateServerMqtt CommunicationAdapter(new MqttTcpChannel(clientSocket, sslStream));
var clientAdapter = _communicationAdapterFactory.CreateServer CommunicationAdapter(new MqttTcpChannel(clientSocket, sslStream));
ClientAccepted?.Invoke(this, new MqttServerAdapterClientAcceptedEventArgs(clientAdapter));
}
catch (Exception exception)