Пример #1
0
 public static bool TryLoginPlayer(int id, ServerClient server)
 {
     lock (syc_obj)
     {
         if (m_players.ContainsKey(id))
         {
             Player player = m_players[id];
             if (player.CurrentServer == null)
             {
                 player.CurrentServer = server;
                 player.State = ePlayerState.Logining;
                 return true;
             }
             else
             {
                 if (player.State == ePlayerState.Play)
                 {
                     player.CurrentServer.SendKitoffUser(id);
                 }
                 return false;
             }
         }
         else
         {
             return false;
         }
     }
 }
Пример #2
0
        public static void PlayerLogined(int id, ServerClient server)
        {
            lock (syc_obj)
            {
                if (!m_players.ContainsKey(id))
                    return;

                Player player = m_players[id];
                if (player != null)
                {
                    player.CurrentServer = server;
                    player.State = ePlayerState.Play;
                }
            }
        }
Пример #3
0
        public int RateUpdate(int serverId)
        {
            ServerClient[] list = this.GetAllClients();
            int            result;

            if (list != null)
            {
                ServerClient[] array = list;
                for (int i = 0; i < array.Length; i++)
                {
                    ServerClient client = array[i];
                    if (client.Info.ID == serverId)
                    {
                        GSPacketIn pkg = new GSPacketIn(177);
                        pkg.WriteInt(serverId);
                        client.SendTCP(pkg);
                        result = 0;
                        return(result);
                    }
                }
            }
            result = 1;
            return(result);
        }
Пример #4
0
 public void SendToALL(GSPacketIn pkg, ServerClient except)
 {
     ServerClient[] list = GetAllClients();
     if (list != null)
     {
         foreach (ServerClient client in list)
         {
             if (client != except)
             {
                 client.SendTCP(pkg);
             }
         }
     }
 }
Пример #5
0
        public new ServerClient[] GetAllClients()
        {
            ServerClient[] list = null;

            lock (_clients.SyncRoot)
            {
                list = new ServerClient[_clients.Count];
                _clients.Keys.CopyTo(list, 0);
            }
            return list;
        }
Пример #6
0
 public static List<Player> GetServerPlayers(ServerClient server)
 {
     List<Player> list = new List<Player>();
     Player[] players = GetAllPlayer();
     foreach (Player p in players)
     {
         if (p.CurrentServer == server)
         {
             list.Add(p);
         }
     }
     return list;
 }