Esempio n. 1
0
        public void Reconnect(bool fireEvent = true)
        {
            if (!IsOpen)
            {
                throw new InvalidOperationException("Canont reconnect, is not open");
            }

            if (fireEvent)
            {
                OnConnection(false);
            }

            IsConnected = false;
            _reconnectThread.Start();
        }
Esempio n. 2
0
        public bool Open()
        {
            if (IsConnected)
            {
                throw new InvalidOperationException("Already connected, Close first");
            }

            if (!_sendSocket.Open())
            {
                return(false);
            }
            if (!_receiveSocket.Open())
            {
                _sendSocket.Close();
                return(false);
            }

            _eventProcessingThread.Start();
            return(true);
        }
Esempio n. 3
0
        public bool Open()
        {
            if (IsOpen)
            {
                throw new InvalidOperationException("Cannot open, already open");
            }

            // Try to create socket
            if (!TryCreateSocket())
            {
                return(false);
            }

            _reconnectThread = new ProcessingThread($"Socket Reconnect Thread (port {_port})", ReconnectIteration);

            OnOpen();

            // Initial state
            IsOpen      = true;
            IsConnected = false;
            _reconnectThread.Start();

            return(true);
        }
Esempio n. 4
0
 protected override void AfterReconnect()
 {
     // Start trying to receive messages again
     _receiveThread?.Start();
 }