Example #1
0
        private void OnDisconnected(object sender, EventArgs e)
        {
            _tickTimer.Stop();
            _guardTimer.Deactivate();

            SysPost.InvokeMulticast(this, LogicallyDisconnected);
        }
Example #2
0
        private bool Handle_HandshakeResponse(eNetCmd cmd, UsCmd c)
        {
            NetUtil.Log("eNetCmd.SV_HandshakeResponse received, connection validated.");

            SysPost.InvokeMulticast(this, LogicallyConnected);

            _guardTimer.Deactivate();
            return(true);
        }
Example #3
0
        public void Disconnect()
        {
            if (_tcpClient != null)
            {
                _tcpClient.Close();
                _tcpClient = null;

                _host = "";
                _port = 0;

                NetUtil.Log("connection closed.");
                SysPost.InvokeMulticast(this, Disconnected);
            }
        }
Example #4
0
        // 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);
            }
        }