Esempio n. 1
0
        public static MailAck Decode(G2Header root)
        {
            MailAck  ack   = new MailAck();
            G2Header child = new G2Header(root.Data);

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

                switch (child.Name)
                {
                case Packet_MailID:
                    ack.MailID = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Source:
                    ack.Source   = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    ack.SourceID = Utilities.KeytoID(ack.Source);
                    break;

                case Packet_Target:
                    ack.Target   = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                    ack.TargetID = Utilities.KeytoID(ack.Target);
                    break;

                case Packet_TargetVersion:
                    ack.TargetVersion = BitConverter.ToUInt32(child.Data, child.PayloadPos);
                    break;

                case Packet_SourceVersion:
                    ack.SourceVersion = BitConverter.ToUInt32(child.Data, child.PayloadPos);
                    break;
                }
            }

            return(ack);
        }
Esempio n. 2
0
        public static MailAck Decode(G2Header root)
        {
            MailAck ack = new MailAck();
            G2Header child = new G2Header(root.Data);

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

                switch (child.Name)
                {
                    case Packet_MailID:
                        ack.MailID = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                        break;

                    case Packet_Source:
                        ack.Source = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                        ack.SourceID = Utilities.KeytoID(ack.Source);
                        break;

                    case Packet_Target:
                        ack.Target = Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize);
                        ack.TargetID = Utilities.KeytoID(ack.Target);
                        break;

                    case Packet_TargetVersion:
                        ack.TargetVersion = BitConverter.ToUInt32(child.Data, child.PayloadPos);
                        break;

                    case Packet_SourceVersion:
                        ack.SourceVersion = BitConverter.ToUInt32(child.Data, child.PayloadPos);
                        break;
                }
            }

            return ack;
        }