private void OnDisconnected(object sender, EventArgs e) { _tickTimer.Stop(); _guardTimer.Deactivate(); SysPost.InvokeMulticast(this, LogicallyDisconnected); }
private bool Handle_HandshakeResponse(eNetCmd cmd, UsCmd c) { NetUtil.Log("eNetCmd.SV_HandshakeResponse received, connection validated."); SysPost.InvokeMulticast(this, LogicallyConnected); _guardTimer.Deactivate(); return(true); }
public void Disconnect() { if (_tcpClient != null) { _tcpClient.Close(); _tcpClient = null; _host = ""; _port = 0; NetUtil.Log("connection closed."); SysPost.InvokeMulticast(this, Disconnected); } }
// Called when a connection to a server is established private void OnConnect(IAsyncResult asyncResult) { // Retrieving TcpClient from IAsyncResult TcpClient tcpClient = (TcpClient)asyncResult.AsyncState; try { if (tcpClient.Connected) // may throw NullReference { NetUtil.Log("connected successfully."); SysPost.InvokeMulticast(this, Connected); } else { throw new Exception(); } } catch (Exception ex) { DisconnectOnError("connection failed while handling OnConnect().", ex); } }