Exemple #1
0
        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;
        }
Exemple #2
0
        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;
        }
Exemple #3
0
        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();
        }
Exemple #4
0
        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();
        }
Exemple #5
0
        public virtual void Close()
        {
            if (!IsOpened)
            {
                return;
            }

            Disconnect();

            udpReceiver.Close();

            tcpConnector = null;
            udpReceiver  = null;
            udpSender    = null;

            IsOpened = false;
        }
Exemple #6
0
        public virtual void Close()
        {
            if (!IsOpened)
            {
                return;
            }

            if (listenPortNumber != 0)
            {
                udpReceiver.Close();
                udpReceiver = null;
            }
            if (sendPortNumber != 0)
            {
                udpSender = null;
            }

            IsOpened = false;
        }
Exemple #7
0
        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();
        }