Ejemplo n.º 1
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))
                ));
 }
Ejemplo n.º 2
0
        public static StreamId Decode(BinaryReader reader)
        {
            var id = P2ptpCommon.DecodeUInt32(reader);

            if (id == 0)
            {
                return(null);
            }
            else
            {
                return(new StreamId(id));
            }
        }
Ejemplo n.º 3
0
        public static StreamId Decode(byte[] data, ref int index)
        {
            var id = P2ptpCommon.DecodeUInt32(data, ref index);

            if (id == 0)
            {
                return(null);
            }
            else
            {
                return(new StreamId(id));
            }
        }
Ejemplo n.º 4
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);
            }
        }