Exemple #1
0
        public static TransferStop Decode(G2Header root)
        {
            TransferStop stop = new TransferStop();

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (child.Name == Packet_Retry)
                {
                    stop.Retry = true;
                }

                if (!G2Protocol.ReadPayload(child))
                {
                    continue;
                }

                switch (child.Name)
                {
                case Packet_FileID:
                    stop.FileID = BitConverter.ToUInt64(child.Data, child.PayloadPos);
                    break;

                case Packet_StartByte:
                    stop.StartByte = CompactNum.ToInt64(child.Data, child.PayloadPos, child.PayloadSize);
                    break;

                case Packet_Index:
                    stop.Index = CompactNum.ToInt32(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(stop);
        }
Exemple #2
0
        public static TransferStop Decode(G2Header root)
        {
            TransferStop stop = new TransferStop();

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (child.Name == Packet_Retry)
                    stop.Retry = true;

                if (!G2Protocol.ReadPayload(child))
                    continue;

                switch (child.Name)
                {
                    case Packet_FileID:
                        stop.FileID = BitConverter.ToUInt64(child.Data, child.PayloadPos);
                        break;

                    case Packet_StartByte:
                        stop.StartByte = CompactNum.ToInt64(child.Data, child.PayloadPos, child.PayloadSize);
                        break;

                    case Packet_Index:
                        stop.Index = CompactNum.ToInt32(child.Data, child.PayloadPos, child.PayloadSize);
                        break;
                }
            }

            return stop;
        }