Exemple #1
0
 //public P2PPacket(EP2PPacket packetID, byte slot, uint ip = 1, ushort port = 1, ushort unk = 0)
 //    : this((byte)packetID, slot, ip, port, unk)
 //{
 //}
 //public P2PPacket(byte packetID, byte slot, uint ip = 1, ushort port = 1, ushort unk = 0)
 //{
 //    _w = new BinaryWriter(new MemoryStream());
 //    _ip = ip;
 //    _port = port;
 //    _unk = unk;
 //    _packetID = (EP2PPacket)packetID;
 //    _slot = slot;
 //}
 public P2PPacket(byte[] data, int offset = 0)
 {
     _r = new BinaryReader(new MemoryStream(data));
     _r.ReadBytes(offset);
     _port = _r.ReadUInt16();
     _ip = _r.ReadUInt32();
     _unk = _r.ReadUInt16();
     _packetID = (EP2PPacket)_r.ReadByte();
     _slot = _r.ReadByte();
     _size = _r.ReadUInt16();
 }
        //public P2PPacket(EP2PPacket packetID, byte slot, uint ip = 1, ushort port = 1, ushort unk = 0)
        //    : this((byte)packetID, slot, ip, port, unk)
        //{

        //}

        //public P2PPacket(byte packetID, byte slot, uint ip = 1, ushort port = 1, ushort unk = 0)
        //{
        //    _w = new BinaryWriter(new MemoryStream());
        //    _ip = ip;
        //    _port = port;
        //    _unk = unk;
        //    _packetID = (EP2PPacket)packetID;
        //    _slot = slot;
        //}

        public P2PPacket(byte[] data, int offset = 0)
        {
            _r = new BinaryReader(new MemoryStream(data));
            _r.ReadBytes(offset);
            _port     = _r.ReadUInt16();
            _ip       = _r.ReadUInt32();
            _unk      = _r.ReadUInt16();
            _packetID = (EP2PPacket)_r.ReadByte();
            _slot     = _r.ReadByte();
            _size     = _r.ReadUInt16();
        }