Example #1
0
 private void ServerComponentOnConnectionStausChanged(object sender, TcpConnectionStatusEventArgs e)
 {
     if (e.Status == TcpConnectionStatus.Disconnected)
     {
         var vars = _ioc.Get <RealmRuntimeVariables>();
         vars.MessageOnExit = "Server connection was interrupted. " + _serverComponent.LastErrorText;
         StatesManager.ActivateGameState("MainMenu");
     }
 }
Example #2
0
        void _serverConnection_StatusChanged(object sender, TcpConnectionStatusEventArgs e)
        {
            bool final = true;

            if (e.Status == TcpConnectionStatus.Disconnected)
            {
                foreach (var message in ServerConnection.FetchPendingMessages())
                {
                    var error = message as ErrorMessage;
                    if (error != null)
                    {
                        _lastError = error;
                    }
                }

                if (_tryingGlobal && _needToTryLocal)
                {
                    // doing second attempt
                    string addr;
                    int    port;

                    ParseAddress(LocalAddress, out addr, out port);
                    _tryingGlobal   = false;
                    _needToTryLocal = false;
                    final           = false;

                    ServerConnection.Connect(addr, port);
                }
            }

            if (e.Status == TcpConnectionStatus.Connected)
            {
                _needToTryLocal = false;
            }

            var ea = new ServerConnectionStatusEventArgs
            {
                Status = e.Status,
                Final  = final,
            };

            OnConnectionStatusChanged(ea);
        }
Example #3
0
        void ConnectionConnectionStatusChanged(object sender, TcpConnectionStatusEventArgs e)
        {
            var connection = sender as ClientConnection;

            if (e.Status == TcpConnectionStatus.Disconnected)
            {
                var ea = new ConnectionEventArgs {
                    Connection = connection
                };
                OnBeforeConnectionRemoved(ea);
                lock (_syncRoot)
                {
                    if (connection != null)
                    {
                        _connections.Remove(connection.Id);
                    }
                }
                OnConnectionRemoved(ea);
            }
        }