public void Reconnect(bool fireEvent = true) { if (!IsOpen) { throw new InvalidOperationException("Canont reconnect, is not open"); } if (fireEvent) { OnConnection(false); } IsConnected = false; _reconnectThread.Start(); }
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); }
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); }
protected override void AfterReconnect() { // Start trying to receive messages again _receiveThread?.Start(); }