Exemplo n.º 1
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            int clientID = packet.ReadInt();
            string account = packet.ReadUTF();
            string nickName = packet.ReadUTF();

            int playerID = 0;

            using (PlayerBussiness pb = new PlayerBussiness())
            {
                playerID = pb.Registe(account, nickName);
            }

            if (playerID != 0)
            {
                ValidateLoginHandler.SendLoginPacket(client, clientID, account, playerID);
            }
            else
            {
                //TODO: 发送创建角色失败给客户端

                RegisteResultPacket pkg = new RegisteResultPacket();

                pkg.ClientID = clientID;

                client.SendTcp(pkg);
            }

            return 0;
        }
Exemplo n.º 2
0
 public void SendToAllServer(GamePacket pkg)
 {
     foreach (ServerConnector connector in m_servers)
     {
         connector.SendTCP(pkg);
     }
 }
Exemplo n.º 3
0
        public int HandlePacket(ServerConnector connector, GamePacket packet)
        {
            uint id = packet.ReadUnsignedByte();

            GatewayGlobal.GatewayID = id;

            return 0;
        }
Exemplo n.º 4
0
        public int HandlePacket(ServerConnector connector, GamePacket packet)
        {
            GatewayPlayer player = GatewayGlobal.Players[packet.PlayerID];

            player.Client.LogicServer.SendTCP(packet);

            return 0;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 复制一个数据包,使用同一个字节流.
        /// </summary>
        /// <returns></returns>
        public GamePacket Clone()
        {
            GamePacket packet = new GamePacket(Buffer, Endian);

            packet.ReadHeader();

            return packet;
        }
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            bool logined = packet.ReadBoolean();

            uint clientID = packet.ReadUnsignedInt();

            return 0;
        }
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            if (packet.Code > 1000)
            {
                client.HandlePacket(packet.Code, packet);
            }

            return 0;
        }
Exemplo n.º 8
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            int gatewayID = packet.ReadInt();
            int clientID = packet.ReadInt();

            ConnectOtherGatewayServer(client, gatewayID, clientID);

            return 0;
        }
Exemplo n.º 9
0
        //public override void HandlePacket(GamePacket packet)
        //{
        //    if (packet != null && packet.Code2 != 0 && packet.Code <= 1000)
        //    {
        //        return;
        //    }
        //    base.HandlePacket(packet);
        //}
        public override void HandlePacket(int code, GamePacket packet)
        {
            if (packet != null && packet.Code2 != 0 && packet.Code <= 1000)
            {
                return;
            }

            base.HandlePacket(code, packet);
        }
Exemplo n.º 10
0
        public virtual void HandlePacket(GamePacket packet)
        {
            if (packet == null)
            {
                log.Error("Packet is null!");
                return;
            }

            HandlePacketImp(packet.Code, packet);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 复制一个数据包,使用同一个字节流.
        /// </summary>
        /// <returns></returns>
        public GamePacket Clone()
        {
            GamePacket packet = new GamePacket();

            packet.CopyFrom(Buffer, 0, 0, Length);

            packet.ReadHeader();

            return packet;
        }
Exemplo n.º 12
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            uint gatewayID = packet.ReadUnsignedInt();

            GatewayInfo info = GameGlobal.GatewayMgr.FindTemplate(gatewayID);

            info.Fulled = false;

            return 0;
        }
Exemplo n.º 13
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            uint clientID = packet.ReadUnsignedInt();

            string account = packet.ReadUTF();

            //TODO: 从数据库验证帐号,成功时记录到CacheGlobal中的LoginPlayerMgr和CachePlayerMgr中.

            return 0;
        }
Exemplo n.º 14
0
        public int HandlePacket(ServerConnector connector, GamePacket packet)
        {
            GatewayPlayer player = GatewayGlobal.Players[packet.PlayerID];

            if (player != null)
            {
                player.SendTcp(packet);
            }

            return 0;
        }
Exemplo n.º 15
0
        public void SendTcp(GamePacket pkg)
        {
            if (pkg == null) return;

            if (pkg.PlayerID == 0)
            {
                pkg.PlayerID = PlayerID;
            }

            Client.SendTcp(pkg);
        }
Exemplo n.º 16
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            Player player = CacheGlobal.CachePlayerMgr.Remove(packet.PlayerID);

            if (player != null)
            {
                CacheGlobal.LoginPlayerMgr.RemovePlayer(player);
            }

            return 0;
        }
Exemplo n.º 17
0
        public int HandlePacket(ServerConnector connector, GamePacket packet)
        {
            LogicServerConnector conn = connector as LogicServerConnector;

            if (conn != null)
            {
                conn.Fulled = false;
            }

            return 0;
        }
Exemplo n.º 18
0
        public int HandlePacket(ServerConnector connector, GamePacket packet)
        {
            if (GatewayGlobal.CacheServer != null && GatewayGlobal.CacheServer.Socket.Connected)
            {
                GatewayGlobal.CacheServer.SendTCP(packet);
            }
            else
            {
                //TODO: 通知客户端没有可用缓存服务器
            }

            return 0;
        }
Exemplo n.º 19
0
        public int HandlePacket(ServerConnector connector, GamePacket packet)
        {
            string ip = packet.ReadUTF();

            int port = packet.ReadInt();

            if (GatewayGlobal.CacheServer == null || GatewayGlobal.CacheServer.Socket.Connected == false)
            {
                GatewayGlobal.CacheServer = new CacheServerConnector(ip, port);
            }

            return 0;
        }
Exemplo n.º 20
0
        public int HandlePacket(ServerConnector connector, GamePacket packet)
        {
            int clientID = packet.ReadInt();

            GatewayClient client = GatewayGlobal.Clients[clientID];

            if (client != null)
            {
                client.SendTcp(packet);
            }

            return 0;
        }
Exemplo n.º 21
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            int clientID = packet.ReadInt();

            CenterPlayer player = CenterGlobal.PlayerMgr[packet.PlayerID];

            if (player != null && player.Client == client && player.ClientID == clientID)
            {
                CenterGlobal.PlayerMgr.Remove(player.PlayerID);
            }

            return 0;
        }
Exemplo n.º 22
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            string account = packet.ReadUTF();

            ValidateLoginPacket pkg = new ValidateLoginPacket();

            pkg.ClientID = ((GatewayClient)client).ClientID;
            pkg.Account = account;

            GatewayGlobal.Send2CacheServer(pkg);

            return 0;
        }
Exemplo n.º 23
0
        public int HandlePacket(ServerConnector connector, GamePacket packet)
        {
            uint clientID = packet.ReadUnsignedInt();

            ClientBase client = GatewayGlobal.PlayerClientMgr[clientID];

            if (client != null)
            {
                client.SendTcp(packet);
            }

            return 0;
        }
Exemplo n.º 24
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            uint gatewayID = packet.ReadUnsignedInt();

            uint clientID = packet.ReadUnsignedInt();

            GatewayInfo info = GameGlobal.GatewayMgr.FindTemplate(gatewayID);

            info.Fulled = true;

            ConnectOtherGatewayHandler.ConnectOtherGatewayServer(client, gatewayID, clientID);

            return 0;
        }
Exemplo n.º 25
0
 protected override void ReceivePacket(GamePacket packet)
 {
     if (packet.Code2 == 0)
     {
         if (GatewayGlobal.PlayerLoginMgr[packet.PlayerID] != null)
         {
             GatewayGlobal.PlayerLoginMgr[packet.PlayerID].SendTcp(packet);
         }
     }
     else
     {
         base.ReceivePacket(packet);
     }
 }
Exemplo n.º 26
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            CenterPlayer player = CenterGlobal.PlayerMgr[packet.PlayerID];

            if (player != null)
            {
                ValidateLoginPacket pkg = new ValidateLoginPacket();
                pkg.PlayerID = player.PlayerID;
                pkg.ClientID = player.ClientID;
                player.SendTcp(pkg);
            }

            return 0;
        }
Exemplo n.º 27
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            int clientID = packet.ReadInt();

            GamePlayer player = GameGlobal.PlayerMgr[packet.PlayerID];

            if (player != null && player.Client == client && player.ClientID == clientID)
            {
                player.SaveToDatabase();

                GameGlobal.PlayerMgr.Remove(packet.PlayerID);
            }

            return 0;
        }
Exemplo n.º 28
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            if (packet == null || packet.Code <= 1000)
            {
                return 0;
            }

            GatewayPlayer c = GatewayGlobal.PlayerLoginMgr[packet.PlayerID];

            if (c != null && c.LogicServer != null)
            {
                c.LogicServer.SendTCP(packet);
            }

            return 0;
        }
Exemplo n.º 29
0
        public int HandlePacket(ServerConnector connector, GamePacket packet)
        {
            uint id = packet.ReadUnsignedInt();

            if (GatewayGlobal.ContainsBattleServer(id))
            {
                return 0;
            }

            string ip = packet.ReadUTF();

            int port = packet.ReadInt();

            new BattleServerConnector(id, ip, port);

            return 0;
        }
Exemplo n.º 30
0
        public virtual void HandlePacket(GamePacket packet)
        {
            if (packet == null)
            {
                log.Error("Packet is null!");
                return;
            }

            if (packet.Code2 == 0)
            {
                HandlePacket(packet.Code, packet);
            }
            else
            {
                HandlePacket(packet.Code2, packet);
            }
        }