/// <summary>
        /// Fecha a conexão do cliente.
        /// </summary>
        /// <param name="destroyConn">Destruir conexão?</param>
        /// <param name="time">Tempo de espera para cancelar o recebimento de pacotes (milissegundos)</param>
        public void Close(bool destroyConnection, int time = 0)
        {
            if (closed)
            {
                return;
            }

            try
            {
                closed = true;
                LoginManager.RemoveSocket(this);
                Account player = _player;
                if (destroyConnection)
                {
                    if (player != null)
                    {
                        player.setOnlineStatus(false);
                        if (player._status.serverId == 0)
                        {
                            SEND_REFRESH_ACC.RefreshAccount(player, false);
                        }
                        player._status.ResetData(player.player_id);
                        player.SimpleClear();
                        player.updateCacheInfo();
                        _player = null;
                    }
                    _client.Close(time);
                    Thread.Sleep(time);
                    Dispose();
                }
                else if (player != null)
                {
                    player.SimpleClear();
                    player.updateCacheInfo();
                    _player = null;
                }
                Auth_SyncNet.UpdateAuthCount(0);
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString());
                Printf.b_danger("[LoginClient.Close] Erro fatal!");
            }
        }
Exemplo n.º 2
0
 public void Close(int time, bool destroyConnection)
 {
     if (this.closed)
     {
         return;
     }
     try
     {
         this.closed = true;
         LoginManager.RemoveSocket(this);
         Account player = this._player;
         if (destroyConnection)
         {
             if (player != null)
             {
                 player.setOnlineStatus(false);
                 if (player._status.serverId == (byte)0)
                 {
                     SEND_REFRESH_ACC.RefreshAccount(player, false);
                 }
                 player._status.ResetData(player.player_id);
                 player.SimpleClear();
                 player.updateCacheInfo();
                 this._player = (Account)null;
             }
             this._client.Close(time);
             Thread.Sleep(time);
             this.Dispose();
         }
         else if (player != null)
         {
             player.SimpleClear();
             player.updateCacheInfo();
             this._player = (Account)null;
         }
         Auth_SyncNet.UpdateGSCount(0);
     }
     catch (Exception ex)
     {
         Logger.warning("[LoginClient.Close] " + ex.ToString());
     }
 }