Procházet zdrojové kódy

Add support for disabling server endpoints (ipv4 or ipv6)

release/3.x.x
Christian Kratky před 6 roky
rodič
revize
2b420b8e66
1 změnil soubory, kde provedl 28 přidání a 21 odebrání
  1. +28
    -21
      Source/MQTTnet/Implementations/MqttTcpServerAdapter.cs

+ 28
- 21
Source/MQTTnet/Implementations/MqttTcpServerAdapter.cs Zobrazit soubor

@@ -1,6 +1,7 @@
#if !WINDOWS_UWP
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
@@ -79,27 +80,33 @@ namespace MQTTnet.Implementations

private void RegisterListeners(MqttServerTcpEndpointBaseOptions options, X509Certificate2 tlsCertificate)
{
var listenerV4 = new MqttTcpServerListener(
AddressFamily.InterNetwork,
options,
tlsCertificate,
_cancellationTokenSource.Token,
_logger);

listenerV4.ClientAccepted += OnClientAccepted;
listenerV4.Start();
_listeners.Add(listenerV4);

var listenerV6 = new MqttTcpServerListener(
AddressFamily.InterNetworkV6,
options,
tlsCertificate,
_cancellationTokenSource.Token,
_logger);

listenerV6.ClientAccepted += OnClientAccepted;
listenerV6.Start();
_listeners.Add(listenerV6);
if (!options.BoundInterNetworkAddress.Equals(IPAddress.None))
{
var listenerV4 = new MqttTcpServerListener(
AddressFamily.InterNetwork,
options,
tlsCertificate,
_cancellationTokenSource.Token,
_logger);

listenerV4.ClientAccepted += OnClientAccepted;
listenerV4.Start();
_listeners.Add(listenerV4);
}

if (!options.BoundInterNetworkV6Address.Equals(IPAddress.None))
{
var listenerV6 = new MqttTcpServerListener(
AddressFamily.InterNetworkV6,
options,
tlsCertificate,
_cancellationTokenSource.Token,
_logger);

listenerV6.ClientAccepted += OnClientAccepted;
listenerV6.Start();
_listeners.Add(listenerV6);
}
}

private void OnClientAccepted(object sender, MqttServerAdapterClientAcceptedEventArgs e)


Načítá se…
Zrušit
Uložit