//----------------[ Configure Operations ]-----------------------// public void SetConnectionConnectedDelegate(ConnectionConnectedDelegate ccd) { lock (interLocker) { connectConnectedDelegate = ccd; } }
private void ConfigConnectedDelegate(TCPConnection conn, ConnectionConnectedDelegate cb, ManualResetEvent finishEvent) { conn.SetConnectedDelegate((Int64 connectionId, string endpoint, bool connected) => { if (!connected) { SetClientStatus(conn, ClientStatus.Closed); } if (cb != null) { try { cb(connectionId, endpoint, connected); } catch (Exception ex) { if (errorRecorder != null) { errorRecorder.RecordError("Connected event exception. Remote endpoint: " + endpoint + ".", ex); } } } if (connected) { SetClientStatus(conn, ClientStatus.Connected); } finishEvent.Set(); }); }
private void ConfigRtmGateClient(TCPClient client, ConnectionConnectedDelegate ccd, int timeout) { client.ConnectTimeout = timeout; client.QuestTimeout = RTMConfig.globalQuestTimeoutSeconds; if (errorRecorder != null) { client.SetErrorRecorder(errorRecorder); } client.SetQuestProcessor(processor); client.SetConnectionConnectedDelegate(ccd); client.SetConnectionCloseDelegate((Int64 connectionId, string endpoint, bool causedByError) => { bool trigger = false; lock (interLocker) { trigger = rtmGateConnectionId == connectionId; } if (trigger) { processor.SessionClosed(causedByError ? com.fpnn.ErrorCode.FPNN_EC_CORE_UNKNOWN_ERROR : com.fpnn.ErrorCode.FPNN_EC_OK); } }); }
//----------------[ callbacks Functions ]-----------------------// private void CallConnectionConnectedDelegate(Int64 connectionId, bool connected, string exceptionMessage) { if (connectConnectedDelegate != null) { try { connectConnectedDelegate(connectionId, endpoint.ToString(), connected); } catch (Exception ex) { if (errorRecorder != null) { errorRecorder.RecordError(exceptionMessage, ex); } } connectConnectedDelegate = null; } }
//----------------[ Configure Operations ]-----------------------// public void SetConnectedDelegate(ConnectionConnectedDelegate cb) { connectConnectedDelegate = cb; }