Пример #1
0
        public PeerHelloPacket(byte[] data)
        {
            if (data.Length < MinEncodedSize)
            {
                throw new ArgumentException(nameof(data));
            }
            var index = P2ptpCommon.HeaderSize;

            FromPeerId      = PeerId.Decode(data, ref index);
            StreamId        = StreamId.Decode(data, ref index);
            ToPeerId        = PeerId.Decode(data, ref index);
            LibraryVersion  = P2ptpCommon.DecodeUInt32(data, ref index);
            ProtocolVersion = P2ptpCommon.DecodeUInt16(data, ref index);
            Status          = (PeerHelloRequestStatus)data[index++];
            RequestTime32   = P2ptpCommon.DecodeUInt32(data, ref index);
            RoleFlags       = data[index++];
            var extensionIdsLength = data[index++];

            ExtensionIds = new string[extensionIdsLength];
            for (byte i = 0; i < extensionIdsLength; i++)
            {
                ExtensionIds[i] = P2ptpCommon.DecodeString1ASCII(data, ref index);
            }
        }
Пример #2
0
 internal static PeersListPacket_SharedPeerIpv4 Decode(byte[] data, ref int index)
 {
     return(new PeersListPacket_SharedPeerIpv4(
                StreamId.Decode(data, ref index),
                PeerId.Decode(data, ref index),
                new IPEndPoint(new IPAddress(P2ptpCommon.DecodeUInt32(data, ref index)), P2ptpCommon.DecodeUInt16(data, ref index))
                ));
 }