Пример #1
0
        public static Dictionary <int, int> GetOnlineForLine()
        {
            Dictionary <int, int> dictionary = new Dictionary <int, int>();

            Player[] allPlayer = LoginMgr.GetAllPlayer();
            Player[] array     = allPlayer;
            for (int i = 0; i < array.Length; i++)
            {
                Player player = array[i];
                if (player.CurrentServer != null)
                {
                    if (dictionary.ContainsKey(player.CurrentServer.Info.ID))
                    {
                        Dictionary <int, int> dictionary2;
                        int iD;
                        (dictionary2 = dictionary)[iD = player.CurrentServer.Info.ID] = dictionary2[iD] + 1;
                    }
                    else
                    {
                        dictionary.Add(player.CurrentServer.Info.ID, 1);
                    }
                }
            }
            return(dictionary);
        }
Пример #2
0
 protected void LoginLapseTimerProc(object sender)
 {
     try
     {
         Player[] list     = LoginMgr.GetAllPlayer();
         long     now      = DateTime.Now.Ticks;
         long     interval = (long)this.m_config.LoginLapseInterval * 60L * 1000L * 10L * 1000L;
         Player[] array    = list;
         for (int i = 0; i < array.Length; i++)
         {
             Player player = array[i];
             if (player.State == ePlayerState.NotLogin)
             {
                 if (player.LastTime + interval < now)
                 {
                     LoginMgr.RemovePlayer(player.Id);
                 }
             }
             else
             {
                 player.LastTime = DateTime.Now.Ticks;
             }
         }
     }
     catch (Exception ex)
     {
         CenterServer.log.Error("LoginLapseTimer callback", ex);
     }
 }
Пример #3
0
        public static bool ValidateLoginAndGetID(string name, string password, ref int userID, ref bool isFirst)
        {
            bool result;

            try
            {
                Player[] list = LoginMgr.GetAllPlayer();
                if (list != null)
                {
                    Player[] array = list;
                    for (int i = 0; i < array.Length; i++)
                    {
                        Player p = array[i];
                        if (p.Name == name && p.Password == password)
                        {
                            userID  = p.Id;
                            isFirst = p.IsFirst;
                            result  = true;
                            return(result);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                CenterServer.log.Error(e);
            }
            result = false;
            return(result);
        }
Пример #4
0
 protected void LoginLapseTimerProc(object sender)
 {
     try
     {
         Player[] allPlayer = LoginMgr.GetAllPlayer();
         long     ticks     = DateTime.Now.Ticks;
         long     num       = (long)this._config.LoginLapseInterval * 10L * 1000L;
         Player[] array     = allPlayer;
         for (int i = 0; i < array.Length; i++)
         {
             Player player = array[i];
             if (player.State == ePlayerState.NotLogin)
             {
                 if (player.LastTime + num < ticks)
                 {
                     LoginMgr.RemovePlayer(player.Id);
                 }
             }
             else
             {
                 player.LastTime = ticks;
             }
         }
     }
     catch (Exception exception)
     {
         if (CenterServer.log.IsErrorEnabled)
         {
             CenterServer.log.Error("LoginLapseTimer callback", exception);
         }
     }
 }
Пример #5
0
 protected void LoginLapseTimerProc(object sender)
 {
     try
     {
         Player[] list     = LoginMgr.GetAllPlayer();
         long     now      = DateTime.Now.Ticks;
         long     interval = (long)_config.LoginLapseInterval * 10 * 1000;
         foreach (Player player in list)
         {
             if (player.State == ePlayerState.NotLogin)
             {
                 if (player.LastTime + interval < now)
                 {
                     LoginMgr.RemovePlayer(player.Id);
                 }
             }
             else
             {
                 player.LastTime = now;
             }
         }
     }
     catch (Exception ex)
     {
         if (log.IsErrorEnabled)
         {
             log.Error("LoginLapseTimer callback", ex);
         }
     }
 }
Пример #6
0
 public bool ValidateLoginAndGetID(string name, string password, ref int userID, ref bool isFirst)
 {
     try
     {
         //Player player = LoginMgr.GetPlayerByName(name);
         //if (player != null && player.Password == password)
         //{
         //    userID = player.Id;
         //    isFirst = player.IsFirst;
         //    return true;
         //}
         Player[] list = LoginMgr.GetAllPlayer();
         if (list != null)
         {
             foreach (Player p in list)
             {
                 if (p.Name == name && p.Password == password)
                 {
                     userID  = p.Id;
                     isFirst = p.IsFirst;
                     return(true);
                 }
             }
         }
     }
     catch
     { }
     return(false);
 }
Пример #7
0
        public static void CreatePlayer(Player player)
        {
            Player older = null;

            lock (syc_obj)
            {
                player.LastTime = DateTime.Now.Ticks;
                if (m_players.ContainsKey(player.Id))
                {
                    older                = m_players[player.Id];
                    player.State         = older.State;
                    player.CurrentServer = older.CurrentServer;
                    m_players[player.Id] = player;
                }
                else
                {
                    older = LoginMgr.GetPlayerByName(player.Name);
                    if (older != null && m_players.ContainsKey(older.Id))
                    {
                        m_players.Remove(older.Id);
                    }
                    player.State = ePlayerState.NotLogin;
                    m_players.Add(player.Id, player);
                }
            }
            if (older != null && older.CurrentServer != null)
            {
                older.CurrentServer.SendKitoffUser(older.Id);
            }
        }
Пример #8
0
 public bool ValidateLoginAndGetID(string name, string password, ref int userID, ref bool isFirst)
 {
     try
     {
         Player[] allPlayer = LoginMgr.GetAllPlayer();
         if (allPlayer != null)
         {
             Player[] array = allPlayer;
             for (int i = 0; i < array.Length; i++)
             {
                 Player player = array[i];
                 if (player.Name == name && player.Password == password)
                 {
                     userID  = player.Id;
                     isFirst = player.IsFirst;
                     return(true);
                 }
             }
         }
     }
     catch
     {
     }
     return(false);
 }
Пример #9
0
        private void HandleUserPrivateMsg(GSPacketIn pkg, int playerid)
        {
            ServerClient client = LoginMgr.GetServerClient(playerid);

            if (client != null)
            {
                client.SendTCP(pkg);
            }
        }
Пример #10
0
        private void HandleUserPrivateMsg(GSPacketIn pkg, int playerid)
        {
            ServerClient serverClient = LoginMgr.GetServerClient(playerid);

            if (serverClient == null)
            {
                return;
            }
            serverClient.SendTCP(pkg);
        }
Пример #11
0
        public void HandleUpdatePlayerState(GSPacketIn pkg)
        {
            Player player = LoginMgr.GetPlayer(pkg.ReadInt());

            if (player == null || player.CurrentServer == null)
            {
                return;
            }
            player.CurrentServer.SendTCP(pkg);
        }
Пример #12
0
        public static ServerClient GetServerClient(int playerId)
        {
            Player player = LoginMgr.GetPlayer(playerId);

            if (player != null)
            {
                return(player.CurrentServer);
            }
            return(null);
        }
Пример #13
0
        public void HandleMarryRoomInfoToPlayer(GSPacketIn pkg)
        {
            int    playerId = pkg.ReadInt();
            Player player   = LoginMgr.GetPlayer(playerId);

            if (player != null && player.CurrentServer != null)
            {
                player.CurrentServer.SendTCP(pkg);
            }
        }
Пример #14
0
        public void HandleUpdatePlayerState(GSPacketIn pkg)
        {
            int    playerId = pkg.ReadInt();
            Player player   = LoginMgr.GetPlayer(playerId);

            if (player != null && player.CurrentServer != null)
            {
                player.CurrentServer.SendTCP(pkg);
            }
        }
Пример #15
0
        public void HandleMarryRoomInfoToPlayer(GSPacketIn pkg)
        {
            Player player = LoginMgr.GetPlayer(pkg.ReadInt());

            if (player == null || player.CurrentServer == null)
            {
                return;
            }
            player.CurrentServer.SendTCP(pkg);
        }
Пример #16
0
        public bool ChargeMoney(int userID, string chargeID)
        {
            ServerClient client = LoginMgr.GetServerClient(userID);

            if (client != null)
            {
                client.SendChargeMoney(userID, chargeID);
                return(true);
            }
            return(false);
        }
Пример #17
0
        private void HandleUserOnline(GSPacketIn pkg)
        {
            int num = pkg.ReadInt();

            for (int index = 0; index < num; ++index)
            {
                int id = pkg.ReadInt();
                pkg.ReadInt();
                LoginMgr.PlayerLogined(id, this);
            }
            this._svr.SendToALL(pkg, this);
        }
Пример #18
0
        private void HandleUserLogin(GSPacketIn pkg)
        {
            int num = pkg.ReadInt();

            if (LoginMgr.TryLoginPlayer(num, this))
            {
                this.SendAllowUserLogin(num, true);
            }
            else
            {
                this.SendAllowUserLogin(num, false);
            }
        }
Пример #19
0
        private void HandleUserOnline(GSPacketIn pkg)
        {
            int count = pkg.ReadInt();

            for (int i = 0; i < count; i++)
            {
                int playerid    = pkg.ReadInt();
                int consortiaid = pkg.ReadInt();
                LoginMgr.PlayerLogined(playerid, this);
                this.Info.Online++;
            }
            this._svr.SendToALL(pkg, this);
        }
Пример #20
0
        /// <summary>
        /// 用户准备登陆
        /// </summary>
        /// <param name="pkg"></param>
        private void HandleUserLogin(GSPacketIn pkg)
        {
            int playerid = pkg.ReadInt();

            if (LoginMgr.TryLoginPlayer(playerid, this))
            {
                SendAllowUserLogin(playerid, true);
            }
            else
            {
                SendAllowUserLogin(playerid, false);
            }
        }
Пример #21
0
        public void HandleQuestUserState(GSPacketIn pkg)
        {
            int num = pkg.ReadInt();

            if (LoginMgr.GetServerClient(num) == null)
            {
                this.SendUserState(num, false);
            }
            else
            {
                this.SendUserState(num, true);
            }
        }
Пример #22
0
        private void HandleUserOffline(GSPacketIn pkg)
        {
            List <int> list = new List <int>();
            int        num  = pkg.ReadInt();

            for (int index = 0; index < num; ++index)
            {
                int id = pkg.ReadInt();
                pkg.ReadInt();
                LoginMgr.PlayerLoginOut(id, this);
            }
            this._svr.SendToALL(pkg);
        }
Пример #23
0
        private void HandleUserOffline(GSPacketIn pkg)
        {
            List <int> users = new List <int>();
            int        count = pkg.ReadInt();

            for (int i = 0; i < count; i++)
            {
                int playerid    = pkg.ReadInt();
                int consortiaid = pkg.ReadInt();
                LoginMgr.PlayerLoginOut(playerid, this);
                this.Info.Online--;
            }
            this._svr.SendToALL(pkg);
        }
Пример #24
0
        public void HandleQuestUserState(GSPacketIn pkg)
        {
            int          playerid = pkg.ReadInt();
            ServerClient client   = LoginMgr.GetServerClient(playerid);

            if (client == null)
            {
                this.SendUserState(playerid, false);
            }
            else
            {
                this.SendUserState(playerid, true);
            }
        }
Пример #25
0
        /// <summary>
        /// 处理用户下线
        /// </summary>
        /// <param name="pkg"></param>
        private void HandleUserOffline(GSPacketIn pkg)
        {
            List <int> users = new List <int>();
            int        count = pkg.ReadInt();

            for (int i = 0; i < count; i++)
            {
                int playerid    = pkg.ReadInt();
                int consortiaid = pkg.ReadInt();
                //判断用户是否在此服务器上,是则成功删除,否则忽略
                LoginMgr.PlayerLoginOut(playerid, this);
            }
            _svr.SendToALL(pkg);
        }
Пример #26
0
 public bool CreatePlayer(int id, string name, string password, bool isFirst)
 {
     try
     {
         Player player = new Player();
         player.Id       = id;
         player.Name     = name;
         player.Password = password;
         player.IsFirst  = isFirst;
         LoginMgr.CreatePlayer(player);
         return(true);
     }
     catch
     { }
     return(false);
 }
Пример #27
0
 public bool KitoffUser(int playerID, string msg)
 {
     try
     {
         ServerClient client = LoginMgr.GetServerClient(playerID);
         if (client != null)
         {
             msg = string.IsNullOrEmpty(msg) ? "You are kicking out by GM!" : msg;
             client.SendKitoffUser(playerID, msg);
             LoginMgr.RemovePlayer(playerID);
             return(true);
         }
     }
     catch {}
     return(false);
 }
Пример #28
0
        protected override void OnDisconnect()
        {
            base.OnDisconnect();
            this._rsa = (RSACryptoServiceProvider)null;
            List <Player> serverPlayers = LoginMgr.GetServerPlayers(this);

            LoginMgr.RemovePlayer(serverPlayers);
            this.SendUserOffline(serverPlayers);
            if (this.Info == null)
            {
                return;
            }
            this.Info.State  = 1;
            this.Info.Online = 0;
            this.Info        = (ServerInfo)null;
        }
Пример #29
0
        public static int GetOnlineCount()
        {
            Player[] allPlayer = LoginMgr.GetAllPlayer();
            int      num       = 0;

            Player[] array = allPlayer;
            for (int i = 0; i < array.Length; i++)
            {
                Player player = array[i];
                if (player.State != ePlayerState.NotLogin)
                {
                    num++;
                }
            }
            return(num);
        }
Пример #30
0
        public static List <Player> GetServerPlayers(ServerClient server)
        {
            List <Player> list = new List <Player>();

            Player[] allPlayer = LoginMgr.GetAllPlayer();
            Player[] array     = allPlayer;
            for (int i = 0; i < array.Length; i++)
            {
                Player player = array[i];
                if (player.CurrentServer == server)
                {
                    list.Add(player);
                }
            }
            return(list);
        }