示例#1
0
文件: LocalSync.cs 项目: nandub/DeOps
        public static ServiceData Decode(byte[] data)
        {
            G2Header root = new G2Header(data);

            G2Protocol.ReadPacket(root);

            if (root.Name != LocationPacket.Data)
            {
                return(null);
            }

            ServiceData packet = new ServiceData();
            G2Header    child  = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_Date:
                    packet.Date = DateTime.FromBinary(BitConverter.ToInt64(child.Data, child.PayloadPos));
                    break;

                case Packet_Tag:
                    packet.Tags.Add(PatchTag.FromBytes(child.Data, child.PayloadPos, child.PayloadSize));
                    break;
                }
            }

            return(packet);
        }
示例#2
0
        public static PatchPacket Decode(G2Header root)
        {
            PatchPacket patch = new PatchPacket();
            G2Header    child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (child.Name == Packet_Patch && G2Protocol.ReadPayload(child))
                {
                    patch.PatchData.Add((PatchTag)PatchTag.FromBytes(child.Data, child.PayloadPos, child.PayloadSize));
                }
            }

            return(patch);
        }