コード例 #1
0
ファイル: TransferPackets.cs プロジェクト: nandub/DeOps
        public static TransferPing Decode(G2Header root)
        {
            TransferPing ping = new TransferPing();

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (child.Name == Packet_RequestInfo)
                {
                    ping.RequestInfo = true;
                }

                if (child.Name == Packet_RequestAlts)
                {
                    ping.RequestAlts = true;
                }

                if (child.Name == Packet_BitfieldUpdated)
                {
                    ping.BitfieldUpdated = true;
                }


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

                switch (child.Name)
                {
                case Packet_Target:
                    ping.Target = BitConverter.ToUInt64(child.Data, child.PayloadPos);
                    break;

                case Packet_Details:
                    ping.Details = FileDetails.Decode(Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize));
                    break;

                case Packet_Status:
                    ping.Status = (TransferStatus)BitConverter.ToInt32(child.Data, child.PayloadPos);
                    break;

                case Packet_MissingDepth:
                    ping.MissingDepth = CompactNum.ToInt32(child.Data, child.PayloadPos, child.PayloadSize);
                    break;
                }
            }

            return(ping);
        }
コード例 #2
0
ファイル: TransferPackets.cs プロジェクト: RoelofSol/DeOps
        public static TransferPing Decode(G2Header root)
        {
            TransferPing ping = new TransferPing();

            G2Header child = new G2Header(root.Data);

            while (G2Protocol.ReadNextChild(root, child) == G2ReadResult.PACKET_GOOD)
            {
                if (child.Name == Packet_RequestInfo)
                    ping.RequestInfo = true;

                if(child.Name == Packet_RequestAlts)
                    ping.RequestAlts = true;

                if (child.Name == Packet_BitfieldUpdated)
                    ping.BitfieldUpdated = true;

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

                switch (child.Name)
                {
                    case Packet_Target:
                        ping.Target = BitConverter.ToUInt64(child.Data, child.PayloadPos);
                        break;

                    case Packet_Details:
                        ping.Details = FileDetails.Decode(Utilities.ExtractBytes(child.Data, child.PayloadPos, child.PayloadSize));
                        break;

                    case Packet_Status:
                        ping.Status = (TransferStatus) BitConverter.ToInt32(child.Data, child.PayloadPos);
                        break;

                    case Packet_MissingDepth:
                        ping.MissingDepth = CompactNum.ToInt32(child.Data, child.PayloadPos, child.PayloadSize);
                        break;
                }
            }

            return ping;
        }