Exemplo n.º 1
0
 public void Reset(RealmOp op)
 {
     _strm.Position = 0;
     _strm.SetLength(0);
     Write((UInt16)0);
     Write((UInt16)op);
 }
Exemplo n.º 2
0
        public PacketOut(RealmOp op)
        {
            type = PacketType.RealmPacket;

            Write((UInt16) 0); //size
            Write((UInt16) op); //op
        }
Exemplo n.º 3
0
        public PacketOut(RealmOp op)
        {
            type = PacketType.RealmPacket;

            Write((UInt16)0);  //size
            Write((UInt16)op); //op
        }
Exemplo n.º 4
0
        public Func <PacketProcessor, PacketProcessResult> GetHandler(RealmOp opcode)
        {
            UInt32 op = (UInt32)opcode;

            Func <PacketProcessor, PacketProcessResult> retval = null;

            PacketHandlers.TryGetValue(op, out retval);
            return(retval);
        }
Exemplo n.º 5
0
        public async Task MovementUpdate(RealmOp opcode, MovementData data)
        {
            //update position
            await UpdatePosition(data.PositionX, data.PositionY, data.PositionZ);

            UpdateOrientation(data.PositionO);

            //send to all for now
            PacketOut pkt = new PacketOut(opcode);

            data.Write(pkt);
            await SendToAll(pkt, false);
        }
Exemplo n.º 6
0
        public void Finalise()
        {
            if (type == PacketType.RealmPacket)
            {
                strm.Position = 0;                  //size
                //Int16 szhs = IPAddress.HostToNetworkOrder((Int16)(strm.Length - 2));
                WriteBE((UInt16)(strm.Length - 2)); //don't include the opcode in the size
                strm.Position = strm.Length;

                strm.Position = 2;
                var op = strm.ReadByte() | (strm.ReadByte() << 8);
                strm.Position = strm.Length;
                RealmOp lol = (RealmOp)op;
                Task.Factory.StartNew(
                    () => { Console.WriteLine("Sending Packet {0} Len {1}", lol.ToString(), strm.Length); });
            }
        }
Exemplo n.º 7
0
        } //shortest is 2 byte size, 4 byte command

        public override PacketProcessResult ProcessData()
        {
            DecryptData(6);
            int sz = CurrentPacket.ReadUInt16BE();

            if ((sz & 0x8000) != 0) //large packet
            {
                DataNeeded = 3;     //we need 3 byte size to continue
                if (CurrentPacket.Length < DataNeeded)
                {
                    return(PacketProcessResult.RequiresData);
                }

                DecryptData(7);
                CurrentPacket.Position = 3;
                sz   = 0;
                sz  |= CurrentPacket.GetBuffer()[0] & 0x7F;
                sz <<= 8;
                sz  |= CurrentPacket.GetBuffer()[1];
                sz <<= 8;
                sz  |= CurrentPacket.GetBuffer()[2];

                DataNeeded = 3 + sz;
                if (CurrentPacket.Length < DataNeeded)
                {
                    return(PacketProcessResult.RequiresData);
                }
            }
            else
            {
                DataNeeded = 2 + sz;
                if (CurrentPacket.Length < DataNeeded)
                {
                    return(PacketProcessResult.RequiresData);
                }
            }

            CurrentOpcode = (RealmOp)CurrentPacket.ReadUInt32();

            Console.WriteLine("Received Packet {0} Length {1}", CurrentOpcode.ToString(), sz);

            //ok now we need sz + 2 to continue

            return(ProcessPacket());
        }
Exemplo n.º 8
0
        } //shortest is 2 byte size, 4 byte command

        public override PacketProcessResult ProcessData()
        {
            DecryptData(6);
            int sz = CurrentPacket.ReadUInt16BE();

            if ((sz & 0x8000) != 0) //large packet
            {
                DataNeeded = 3; //we need 3 byte size to continue
                if (CurrentPacket.Length < DataNeeded) return PacketProcessResult.RequiresData;

                DecryptData(7);
                CurrentPacket.Position = 3;
                sz = 0;
                sz |= CurrentPacket.GetBuffer()[0] & 0x7F;
                sz <<= 8;
                sz |= CurrentPacket.GetBuffer()[1];
                sz <<= 8;
                sz |= CurrentPacket.GetBuffer()[2];

                DataNeeded = 3 + sz;
                if (CurrentPacket.Length < DataNeeded) return PacketProcessResult.RequiresData;
            }
            else
            {
                DataNeeded = 2 + sz;
                if (CurrentPacket.Length < DataNeeded) return PacketProcessResult.RequiresData;
            }

            CurrentOpcode = (RealmOp) CurrentPacket.ReadUInt32();

            Console.WriteLine("Received Packet {0} Length {1}", CurrentOpcode.ToString(), sz);

            //ok now we need sz + 2 to continue

            return ProcessPacket();
        }
Exemplo n.º 9
0
        public Func<PacketProcessor, PacketProcessResult> GetHandler(RealmOp opcode)
        {
            UInt32 op = (UInt32) opcode;

            Func<PacketProcessor, PacketProcessResult> retval = null;
            PacketHandlers.TryGetValue(op, out retval);
            return retval;
        }
Exemplo n.º 10
0
 public PacketHandlerAttribute(RealmOp op)
 {
     Type = PacketType.RealmPacket;
     Id   = (UInt32)op;
 }
Exemplo n.º 11
0
 public void Reset(RealmOp op)
 {
     _strm.Position = 0;
     _strm.SetLength(0);
     Write((UInt16) 0);
     Write((UInt16) op);
 }
Exemplo n.º 12
0
 public PacketHandlerAttribute(RealmOp op)
 {
     Type = PacketType.RealmPacket;
     Id = (UInt32)op;
 }