public virtual void Open() { if (IsOpened) { return; } if (Global.UseSyncContextPost && Global.SyncContext == null) { Global.SyncContext = SynchronizationContext.Current; } if (sendPortNumber != 0) { udpSender = new UDPSender(sendPortNumber, bufferSize); } if (listenPortNumber != 0) { udpReceiver = new UDPReceiver(listenPortNumber, bufferSize); udpReceiver.OnReceive += OnUDPReceived; udpReceiver.Start(); } IsOpened = true; }
public void Close() { if (!IsOpened) { return; } beaconTimer.Stop(); var nMap = new Dictionary <string, ComNode>(nodeMap); foreach (var node in nMap) { ((ComTCPNode)node.Value).Connection.Disconnect(); } tcpListener.Stop(); udpReceiver.Close(); beaconTimer = null; tcpListener = null; udpReceiver = null; udpSender = null; IsOpened = false; }
public void Open() { if (IsOpened) { return; } if (Global.UseSyncContextPost && Global.SyncContext == null) { Global.SyncContext = SynchronizationContext.Current; } udpSender = new UDPSender(sendPortNumber, bufferSize); udpReceiver = new UDPReceiver(listenPortNumber, bufferSize); tcpListener = new TCPListener(listenPortNumber); tcpListener.ConnectionBufferSize = bufferSize; tcpListener.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); tcpListener.OnConnected += OnConnectedInternal; beaconTimer = new System.Timers.Timer(BeaconIntervalMs); udpReceiver.OnReceive += OnUDPReceived; beaconTimer.Elapsed += OnBeaconTimer; tcpListener.Start(); udpReceiver.Start(); IsOpened = true; HealthCheck(); }
public virtual void Open() { if (IsOpened) { return; } if (Global.UseSyncContextPost && Global.SyncContext == null) { Global.SyncContext = SynchronizationContext.Current; } udpSender = new UDPSender(sendPortNumber, bufferSize); udpReceiver = new UDPReceiver(listenPortNumber, bufferSize); tcpConnector = new TCPConnector(sendPortNumber); tcpConnector.ConnectionBufferSize = bufferSize; tcpConnector.ConnectTimeOutMilliSec = connectTimeOutMilliSec; tcpConnector.OnConnected += OnConnectedInternal; udpReceiver.OnReceive += OnUDPReceived; udpReceiver.Start(); IsOpened = true; HealthCheck(); }
public virtual void Close() { if (!IsOpened) { return; } Disconnect(); udpReceiver.Close(); tcpConnector = null; udpReceiver = null; udpSender = null; IsOpened = false; }
public virtual void Close() { if (!IsOpened) { return; } if (listenPortNumber != 0) { udpReceiver.Close(); udpReceiver = null; } if (sendPortNumber != 0) { udpSender = null; } IsOpened = false; }
public virtual void Open() { if (IsOpened) { return; } udpSender = new UDPSender(sendPortNumber, bufferSize); udpReceiver = new UDPReceiver(listenPortNumber, bufferSize); tcpConnector = new TCPConnector(sendPortNumber); tcpConnector.ConnectionBufferSize = bufferSize; tcpConnector.OnConnected += OnConnectedInternal; udpReceiver.OnReceive += OnUDPReceived; udpReceiver.Start(); IsOpened = true; HealthCheck(); }