public Subscribe(FixedHeader header, byte[] data) : base(header) { if (header.RemainingLength > 0) { using (var stream = new MemoryStream(data)) { if (Header.QualityOfService != QualityOfService.AtMostOnce) { MessageId = MessageId.FromStream(stream); while (stream.Position < stream.Length) { Subscriptions.Add(new Subscription(MqString.FromStream(stream), (QualityOfService)stream.ReadBytesOrFailAsync(1).Await().Result[0])); } } } } }
public SubAck(FixedHeader header, byte[] data) : base(header) { if (data == null) { throw new ArgumentNullException("data"); } using (var stream = new MemoryStream(data)) { _grants = new List<QualityOfService>(); MessageId = MessageId.FromStream(stream); while (stream.Position < stream.Length) { byte qosByte = stream.ReadBytesOrFailAsync(1).Await().Result[0]; qosByte = (byte)(qosByte & 0x03); // 00000011 _grants.Add((QualityOfService)qosByte); } } }