Пример #1
0
        public static CommData Decode(G2Header root)
        {
            CommData data = new CommData();

            G2Header child = new G2Header(root.Data);

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

                switch (child.Name)
                {
                case Packet_Service:
                    data.Service = CompactNum.ToUInt32(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_DataType:
                    data.DataType = CompactNum.ToUInt32(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Data:
                    data.Data = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(data);
        }
Пример #2
0
        public static CommData Decode(G2Header root)
        {
            CommData data = new CommData();

            G2Header child = new G2Header(root.Data);

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

                switch (child.Name)
                {
                    case Packet_Service:
                        data.Service = CompactNum.ToUInt32(child.Data, child.PayloadPos, child.PayloadSize);
                        break;

                    case Packet_DataType:
                        data.DataType = CompactNum.ToUInt32(child.Data, child.PayloadPos, child.PayloadSize);
                        break;

                    case Packet_Data:
                        data.Data = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                        break;
                }
            }

            return data;
        }