Esempio n. 1
0
        public bool RemovePlayer(Account player)
        {
            bool result = false;

            try
            {
                player.channelId = -1;
                if (player.session != null)
                {
                    lock (players)
                    {
                        result = players.Remove(player.session);
                    }
                    if (result)
                    {
                        ServersManager.UpdateServerPlayers();
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
            }
            return(result);
        }
Esempio n. 2
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
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
 public bool AddPlayer(PlayerSession playerSession)
 {
     lock (players)
     {
         try
         {
             if (!players.Contains(playerSession))
             {
                 players.Add(playerSession);
                 ServersManager.UpdateServerPlayers();
                 return(true);
             }
         }
         catch (Exception ex)
         {
             Logger.Exception(ex);
         }
     }
     return(false);
 }