示例#1
0
        public bool handlePacket <T>(Kaminari.PacketReader packet, T client, ushort blockId) where T : Kaminari.IBaseClient
        {
            switch (packet.getOpcode())
            {
            case (ushort)Opcodes.opcodeMove:
                return(handleMove(this, packet, (IClient)client, blockId));

            case (ushort)Opcodes.opcodeHandshake:
                return(handleHandshake(this, packet, (IClient)client, blockId));

            case (ushort)Opcodes.opcodeLoginCharacter:
                return(handleLoginCharacter(this, packet, (IClient)client, blockId));

            case (ushort)Opcodes.opcodeLogin:
                return(handleLogin(this, packet, (IClient)client, blockId));

            case (ushort)Opcodes.opcodeCreateCharacter:
                return(handleCreateCharacter(this, packet, (IClient)client, blockId));

            case (ushort)Opcodes.opcodeClientUpdate:
                return(handleClientUpdate(this, packet, (IClient)client, blockId));

            default:
                return(false);
            }
        }
示例#2
0
        private bool handleMove(Kaminari.IMarshal marshal, Kaminari.PacketReader packet, IClient client, ushort blockId)
        {
            if (!client.check(client, "status", ingame_status::in_world))
            {
                return(client.handleClientError(client, packet.getOpcode()));
            }
            if (Overflow.leq(blockId, moveLastCalled))
            {
                // TODO: Returning true here means the packet is understood as correctly parsed, while we are ignoring it
                return(true);
            }
            var data = emplaceData(move, blockId, packet.timestamp());

            if (!data.unpack(marshal, packet))
            {
                return(false);
            }
            // The user is assumed to provide all peek methods in C#
            // TODO: Test if the method exists in the class
            return(client.peekMove(data, packet.timestamp()));
        }