示例#1
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            int gatewayID = packet.ReadInt();
            int clientID = packet.ReadInt();

            ConnectOtherGatewayServer(client, gatewayID, clientID);

            return 0;
        }
示例#2
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;
        }
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            int gatewayID = packet.ReadInt();

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

            info.Fulled = false;

            return 0;
        }
        public int HandlePacket(ServerConnector connector, GamePacket packet)
        {
            int id = packet.ReadInt();

            if (GatewayGlobal.BattleServerMgr.Contains(id) ||
                GatewayGlobal.LogicConnectingMgr.Contains(id))
            {
                return 0;
            }

            string ip = packet.ReadUTF();

            int port = packet.ReadInt();

            LogicServerConnector conn = new LogicServerConnector(id);

            conn.Connect(ip, port);

            return 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;
        }
        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;
        }
        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;
        }
        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;
        }
        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;
        }
示例#10
0
        public int HandlePacket(ServerConnector connector, GamePacket packet)
        {
            int clientID = packet.ReadInt();

            GatewayClient client = GatewayGlobal.Clients[clientID];

            LoginInfo info = new LoginInfo();

            info.PlayerID = packet.PlayerID;

            GatewayPlayer player = new GatewayPlayer(info, client);

            GatewayGlobal.Players.Add(packet.PlayerID, player);

            packet.Code2 = (int)BasePacketCode.None_Code;

            player.Client.LogicServer.SendTCP(packet);

            return 0;
        }
示例#11
0
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            int clientID = packet.ReadInt();

            LoginInfo info = new LoginInfo();

            info.PlayerID = packet.PlayerID;

            GamePlayer player = new GamePlayer(info, client as GameClient);

            player.ClientID = clientID;

            player.Logined();

            GameGlobal.PlayerMgr.Add(player.PlayerID, player);

            GameGlobal.CheckMaxClientCount();

            return 0;
        }
        public int HandlePacket(ClientBase client, GamePacket packet)
        {
            CenterClient center = client as CenterClient;

            ServerType type = (ServerType)packet.ReadUnsignedByte();

            string ip = packet.ReadUTF();

            int port = packet.ReadInt();

            uint id = 0;

            switch (type)
            {
                //case ServerType.UnKnowServer:
                //    break;
                //case ServerType.CenterServer:
                //    break;
                case ServerType.CacheServer:
                    id = 1;
                    if (CenterServerConfig.Configuration.CacheIP == ip && CenterServerConfig.Configuration.CachePort == port)
                    {
                        CenterGlobal.CacheServer = center;

                        CenterGlobal.GatewayServerMgr.ForEach((c) =>
                        {
                            ConnectCacheServerPacket pkg = new ConnectCacheServerPacket();
                            pkg.IP = ip;
                            pkg.Port = port;
                            c.SendTcp(pkg);
                        });
                    }
                    break;
                case ServerType.LogicServer:
                    id = GameGlobal.GameLogicMgr.GetID(info => info.IP == ip && info.Port == port);
                    if (id > 0)
                    {
                        CenterGlobal.GameLogicServerMgr.Add(id, center);
                        CenterGlobal.GatewayServerMgr.ForEach((c) => {
                            ConnectLogicServerPacket pkg = new ConnectLogicServerPacket();
                            pkg.ID = id;
                            pkg.IP = ip;
                            pkg.Port = port;
                            c.SendTcp(pkg);
                        });
                    }
                    break;
                case ServerType.BattleServer:
                    id = GameGlobal.BattleMgr.GetID(info => info.IP == ip && info.Port == port);
                    if (id > 0)
                    {
                        CenterGlobal.BattleServerMgr.Add(id, center);
                        CenterGlobal.GatewayServerMgr.ForEach((c) =>
                        {
                            ConnectBattleServerPacket pkg = new ConnectBattleServerPacket();
                            pkg.ID = id;
                            pkg.IP = ip;
                            pkg.Port = port;
                            c.SendTcp(pkg);
                        });
                    }
                    break;
                case ServerType.GatewayServer:
                    id = GameGlobal.GatewayMgr.GetID(info => info.IP == ip && info.Port == port);

                    UpdateServerIDPacket pkt = new UpdateServerIDPacket();
                    pkt.ID = (byte)id;
                    center.SendTcp(pkt);

                    if (id > 0)
                    {
                        CenterGlobal.GatewayServerMgr.Add(id, center);

                        uint[] keys = CenterGlobal.GameLogicServerMgr.GetKeys();

                        foreach (uint key in keys)
                        {
                            GameLogicInfo info = GameGlobal.GameLogicMgr.FindTemplate(key);
                            ConnectLogicServerPacket pkg = new ConnectLogicServerPacket();
                            pkg.ID = key;
                            pkg.IP = info.IP;
                            pkg.Port = info.Port;
                            center.SendTcp(pkg);
                        }

                        keys = CenterGlobal.BattleServerMgr.GetKeys();
                        foreach (uint key in keys)
                        {
                            BattleInfo info = GameGlobal.BattleMgr.FindTemplate(key);
                            ConnectBattleServerPacket pkg = new ConnectBattleServerPacket();
                            pkg.ID = key;
                            pkg.IP = info.IP;
                            pkg.Port = info.Port;
                            center.SendTcp(pkg);
                        }

                        if (CenterGlobal.CacheServer != null && CenterGlobal.CacheServer.Connected)
                        {
                            ConnectCacheServerPacket cachePacket = new ConnectCacheServerPacket();
                            cachePacket.IP = CenterServerConfig.Configuration.CacheIP;
                            cachePacket.Port = CenterServerConfig.Configuration.CachePort;
                            center.SendTcp(cachePacket);
                        }
                    }
                    break;
                default:
                    center.Disconnect();
                    return 0;
            }

            if (id > 0)
            {
                center.ID = id;
                center.Type = type;
                center.Validated = true;
            }
            else
            {
                center.Disconnect();
            }

            return 0;
        }