Exemple #1
0
        internal static void OnC2SAskEnterGame(ByteBuffer buffer, Connection connection)
        {
            var incPacket = new ConnectionPackets.C2SAskEnterGame(buffer, connection);
            var client    = ClientManager.GetClient(connection);
            var userId    = client.UserId;

            DatabaseFunctions.GetFullCharacter(userId, incPacket.charSlot, out var fullCharBytes);
            var character = new Character(fullCharBytes);

            client.SelectCharacter(character);
            var playerInfoPacket = new CharacterPackets.S2CCharacterInfo(character);

            playerInfoPacket.Send(connection);

            var skillInfoPacket = new CharacterPackets.S2CSkillInfo(character);

            skillInfoPacket.Send(connection);

            var quickInfoPacket = new CharacterPackets.S2CQuickInfo(character);

            quickInfoPacket.Send(connection);

            var styleInfoPacket = new CharacterPackets.S2CStyleInfo(character);

            styleInfoPacket.Send(connection);

            var stateInfoPacket = new CharacterPackets.S2CStatePacket(character);

            stateInfoPacket.Send(connection);

            var packet = new ConnectionPackets.S2CAnsEnterGame(client.UserId);

            packet.Send(connection);
        }
        public static void RegisterDBPackets()
        {
            connection.AppendIncomingPacketHandler <byte[]>("CharacterCreateSuccess",
                                                            (header, connection, character) =>
            {
                ByteBuffer buffer  = new ByteBuffer(character);
                var userID         = BitConverter.ToInt32(buffer.ReadBlock(5), 0);
                var characterbytes = buffer.ReadBlock(buffer.Data.Length - 5);
                var cc             = CCM.GetClientConnection(userID);
                //var charstruct = new PacketStructs.CharacterInfo(character);
                var packet = new CharacterPackets.S2CAnsCreateCharacter(characterbytes, cc.AgentConnection);
                packet.Send(cc.AgentConnection);
            });
            connection.AppendIncomingPacketHandler <byte[]>("CharacterList", ((header, connection1, bytes) =>
            {
                ByteBuffer buffer = new ByteBuffer(bytes);
                var userID = BitConverter.ToInt32(buffer.ReadBlock(4), 0);
                var cc = CCM.GetClientConnection(userID);
                var packet = new ConnectionPackets.S2CAnsEnterCharSelect(buffer.Data);
                packet.Send(cc.AgentConnection);
            }));
            connection.AppendIncomingPacketHandler <int>("CharacterDeleteSuccess", (
                                                             (header, connection1, userID) =>
            {
                var conn = CCM.GetClientConnection(userID).AgentConnection;
                var packet = new CharacterPackets.S2CAnsDeleteCharacter(conn);
                packet.Send(conn);
            }));
            connection.AppendIncomingPacketHandler <int[]>("CharacterDeleteFailed", (
                                                               (header, connection1, incomingObject) =>
            {
                var conn = CCM.GetClientConnection(incomingObject[1]).AgentConnection;
                var errorCode = incomingObject[0];
                var packet = new CharacterPackets.S2CErrCharacterPacket(errorCode, conn);
                packet.Send(conn);
            }));
            connection.AppendIncomingPacketHandler <int>("CheckDuplicateNameSuccess", (
                                                             (header, connection1, incomingObject) =>
            {
            }));
            connection.AppendIncomingPacketHandler <int>("CheckDuplicateNameFailed", (
                                                             (header, connection1, incomingObject) =>
            {
                var conn = CCM.GetClientConnection(incomingObject).AgentConnection;
                var packet = new CharacterPackets.S2CAnsDuplicateNameCheck(0, connection);     //0 oder 5
                packet.Send(conn);
            }));
            connection.AppendIncomingPacketHandler <byte[]>("FullCharacterBytes", ((header, connection1,
                                                                                    fullCharacterBytes) =>
            {
                var userID = BitConverter.ToInt32(ByteUtils.SlicedBytes(fullCharacterBytes, 4, 8), 0);
                var conn = CCM.GetClientConnection(userID);
                var character = new Character(fullCharacterBytes);
                conn.Character = character;
                var playerInfoPacket = new CharacterPackets.S2CCharacterInfo(character);
                playerInfoPacket.Send(conn.AgentConnection);

                var skillInfoPacket = new CharacterPackets.S2CSkillInfo(character);
                skillInfoPacket.Send(conn.AgentConnection);

                var quickInfoPacket = new CharacterPackets.S2CQuickInfo(character);
                quickInfoPacket.Send(conn.AgentConnection);

                var styleInfoPacket = new CharacterPackets.S2CStyleInfo(character);
                styleInfoPacket.Send(conn.AgentConnection);

                var stateInfoPacket = new CharacterPackets.S2CStatePacket(character);
                stateInfoPacket.Send(conn.AgentConnection);

                var packet = new ConnectionPackets.S2CAnsEnterGame(character.Id);
                packet.Send(conn.AgentConnection);
            }));
        }