private void CloseWhenConnectingError() { ClientEngine.UnregisterConnection(this); lock (interLocker) { if (status == TCPClient.ClientStatus.Closed) { return; } status = TCPClient.ClientStatus.Closed; beginClosing = true; } CallConnectionConnectedDelegate(0, false, "Connecting failed event exception. Remote endpoint: " + endpoint + "."); connectionCloseDelegate = null; ClearAllCallback(ErrorCode.FPNN_EC_CORE_INVALID_CONNECTION); socket.Close(); }
private void CleanForClose(bool callCloseEvent, bool causedByError) { ClientEngine.UnregisterConnection(this); ClearAllCallback(ErrorCode.FPNN_EC_CORE_CONNECTION_CLOSED); if (callCloseEvent && connectionCloseDelegate != null) { try { connectionCloseDelegate(connectionId, endpoint.ToString(), causedByError); } catch (Exception ex) { if (errorRecorder != null) { errorRecorder.RecordError("Close event exception. Remote endpoint: " + endpoint + ".", ex); } } } connectionCloseDelegate = null; }