Exemplo n.º 1
0
        public override void Close(int time = 0, bool kicked = false)
        {
            if (ConnectionIsClosed)
            {
                return;
            }
            ConnectionIsClosed = true;
            try
            {
                FirewallSecurity.RemoveRuleUdp(GetIPAddress(), SessionPort);
                GameManager.RemoveSession(this);
                if (SessionPlayer != null)
                {
                    Channel channel = SessionPlayer.GetChannel();
                    Room    room    = SessionPlayer.room;
                    Match   match   = SessionPlayer.match;
                    SessionPlayer.SetOnlineStatus(false);
                    if (room != null)
                    {
                        room.RemovePlayer(SessionPlayer, false, kicked ? 1 : 0);
                    }
                    if (match != null)
                    {
                        match.RemovePlayer(SessionPlayer);
                    }
                    if (channel != null)
                    {
                        channel.RemovePlayer(SessionPlayer);
                    }

                    SessionPlayer.status.ResetData(SessionPlayer.playerId);

                    SessionPlayer.SyncPlayerToFriends(false);
                    SessionPlayer.SyncPlayerToClanMembers();

                    ApiManager.SendPacketToAllClients(new API_USER_DISCONNECT_ACK(SessionPlayer, 0));
                    ApiManager.SendPacketToAllClients(new API_SERVER_INFO_ACK());

                    SessionPlayer.GameClear();
                    SessionPlayer.UpdateCacheInfo();
                    SessionPlayer = null;
                }
                if (SessionSocket != null)
                {
                    SessionSocket.Close(time);
                    Thread.Sleep(time);
                }
                FirewallSecurity.RemoveRuleTcp(GetIPAddress());
                Dispose();
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
            }
            ServersManager.UpdateServerPlayers(); //Auth
        }
Exemplo n.º 2
0
        public override void Close(int time = 0, bool destroy = true)
        {
            if (ConnectionIsClosed)
            {
                return;
            }
            ConnectionIsClosed = true;
            try
            {
                AuthManager.RemoveSession(this);
                if (destroy)
                {
                    if (SessionPlayer != null)
                    {
                        SessionPlayer.SetOnlineStatus(false);
                        SessionPlayer.status.ResetData(SessionPlayer.playerId);

                        SessionPlayer.SyncPlayerToFriends(false);
                        SessionPlayer.SyncPlayerToClanMembers();

                        ApiManager.SendPacketToAllClients(new API_SERVER_INFO_ACK());

                        SessionPlayer.GameClear();
                        SessionPlayer.UpdateCacheInfo();
                        SessionPlayer = null;
                    }
                    if (SessionSocket != null)
                    {
                        SessionSocket.Close(time);
                        Thread.Sleep(time);
                        FirewallSecurity.RemoveRuleTcp(GetIPAddress());
                    }
                    Dispose();
                }
                else if (SessionPlayer != null)
                {
                    SessionPlayer.client = null;
                    SessionPlayer.UpdateCacheInfo();
                    SessionPlayer = null;
                }
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
            }
            ServersManager.UpdateServerPlayers();
        }