예제 #1
0
 protected virtual void OnConnectionStatusChanged(ServerConnectionStatusEventArgs e)
 {
     if (ConnectionStatusChanged != null)
     {
         ConnectionStatusChanged(this, e);
     }
 }
예제 #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);
        }