示例#1
0
        public static FixedHeader Load(NetworkConnection connection)
        {
            byte firstByte = connection.ReadBytesOrFailAsync(1).Await().Result[0];

            var header = new FixedHeader
            {
                Message          = (CommandMessage)((firstByte & 0xF0) >> 4),
                Duplicate        = (firstByte & 0x8) == 0x8,
                QualityOfService = (QualityOfService)((firstByte & 0x6) >> 1),
                Retain           = (firstByte & 0x1) == 0x1,
                RemainingLength  = VariableLengthInteger.Load(connection)
            };

            return(header);
        }
示例#2
0
        public static FixedHeader Load(NetworkConnection connection)
        {
            byte firstByte = connection.Stream.ReadBytesOrFailAsync(1).Await <byte[]>().Result[0];

            FixedHeader header = new FixedHeader();

            header.Message          = (CommandMessage)((firstByte & 0xF0) >> 4);
            header.Duplicate        = (firstByte & 0x8) == 0x8;
            header.QualityOfService = (QualityOfService)((firstByte & 0x6) >> 1);
            header.Retain           = (firstByte & 0x1) == 0x1;

            header.RemainingLength = VariableLengthInteger.Load(connection);

            return(header);
        }