public void Close() { if (!IsOpened) { return; } healthTimer.Stop(); removeNodeCheckTimer.Stop(); var nMap = new Dictionary <IPEndPoint, ComNode>(nodeTcpMap); foreach (var node in nMap) { ((ComSnowballNode)node.Value).Connection.Disconnect(); } tcpListener.Stop(); udpTerminal.Close(); tcpListener = null; udpTerminal = null; IsOpened = false; }
public void Open() { if (IsOpened) { return; } if (userSyncContext) { syncContext = SynchronizationContext.Current; if (syncContext == null) { syncContext = new SnowballSynchronizationContext(10); SynchronizationContext.SetSynchronizationContext(syncContext); } } int port = portNumber; if (listenPortNumber != 0) { port = listenPortNumber; } udpTerminal = new UDPTerminal(port, bufferSize); udpTerminal.SyncContext = syncContext; udpTerminal.OnReceive += OnUnreliableReceived; udpTerminal.ReceiveStart(); IsOpened = true; }
public void BeaconStop() { if (beaconTimer != null) { beaconTimer.Stop(); beaconTimer = null; udpBeaconSender.Close(); udpBeaconSender = null; } }
public void BeaconStart() { if (udpBeaconSender == null) { udpBeaconSender = new UDPTerminal(UDPTerminal.DefaultBufferSize); udpBeaconSender.SyncContext = syncContext; beaconTimer = new System.Timers.Timer(BeaconIntervalMs); beaconTimer.Elapsed += OnBeaconTimer; beaconTimer.Start(); } }
public void Close() { if (!IsOpened) { return; } if (udpTerminal != null) { udpTerminal.Close(); udpTerminal = null; } IsOpened = false; }
public void Open() { if (IsOpened) { return; } if (userSyncContext) { syncContext = SynchronizationContext.Current; if (syncContext == null) { syncContext = new SnowballSynchronizationContext(10); SynchronizationContext.SetSynchronizationContext(syncContext); } } RSAParameters publicKey; RSAParameters privateKey; RsaKeyGenerate(out publicKey, out privateKey); RsaPublicKey = publicKey; RsaPrivateKey = privateKey; rsaDecrypter = new RsaDecrypter(RsaPrivateKey); udpTerminal = new UDPTerminal(portNumber, bufferSize); udpTerminal.SyncContext = syncContext; udpTerminal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); tcpListener = new TCPListener(portNumber); tcpListener.SyncContext = syncContext; tcpListener.ConnectionBufferSize = bufferSize; tcpListener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); tcpListener.OnConnected += OnConnectedInternal; udpTerminal.OnReceive += OnUnreliableReceived; tcpListener.Start(); udpTerminal.ReceiveStart(); IsOpened = true; healthTimer.Start(); removeNodeCheckTimer.Start(); }
public void Close() { if (!IsOpened) { return; } healthTimer.Stop(); AcceptBeacon = false; Disconnect(); udpTerminal.Close(); tcpConnector = null; udpTerminal = null; IsOpened = false; }
public void Open() { if (IsOpened) { return; } if (userSyncContext) { syncContext = SynchronizationContext.Current; if (syncContext == null) { syncContext = new SnowballSynchronizationContext(10); SynchronizationContext.SetSynchronizationContext(syncContext); } } int port = PortNumber; if (listenPortNumber != 0) { port = listenPortNumber; } udpTerminal = new UDPTerminal(port, bufferSize); udpTerminal.SyncContext = syncContext; udpTerminal.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); udpTerminal.OnReceive += OnUnreliableReceived; tcpConnector = new TCPConnector(portNumber); tcpConnector.SyncContext = syncContext; tcpConnector.ConnectionBufferSize = bufferSize; tcpConnector.ConnectTimeOutMilliSec = connectTimeOutMilliSec; tcpConnector.OnConnected += OnConnectedInternal; IsOpened = true; healthTimer.Start(); UdpCheck(); }