public static XorMappedAddressAttribute FromGenericAttribute(MessageAttribute attr, byte[] transactionId)
 {
     return(new XorMappedAddressAttribute(transactionId)
     {
         Type = attr.Type,
         AttributeLength = attr.AttributeLength,
         Value = attr.Value
     });
 }
Beispiel #2
0
        public static Message Parse(ReadOnlySpan <byte> bytes)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }
            if (bytes.Length < 20)
            {
                throw new ArgumentOutOfRangeException(nameof(bytes), "Messages must be at least 20 bytes long");
            }

            var header = MessageHeader.Parse(bytes.Slice(0, 20));

            var ret = new Message
            {
                Header     = header,
                Attributes = bytes.Length > 20 ? MessageAttribute.ParseList(bytes.Slice(20).ToArray(), header.TransactionId).ToList() : null
            };

            return(ret);
        }