internal static V3ConnectVariableHeader FromStream(Stream stream) { var header = new V3ConnectVariableHeader { ProtocolName = MqString.FromStream(stream), Protocolversion = stream.ReadBytesOrFailAsync(1).Await().Result[0], ConnectFlags = ConnectFlags.FromStream(stream), KeepAliveTimer = stream.ReadUint16() }; return(header); }
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 Unsubscribe(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) { _topics.Add(MqString.FromStream(stream)); } } } } }
private void LoadPayload(Stream data) { ClientIdentifier = MqString.FromStream(data); if (Details.ConnectFlags.Will) { WillTopic = MqString.FromStream(data); WillMessage = MqString.FromStream(data); } if (Details.ConnectFlags.UserName) { UserName = MqString.FromStream(data); } if (Details.ConnectFlags.Password) { Password = MqString.FromStream(data); } }
public Publish(FixedHeader header, byte[] data) : base(header) { if (header.RemainingLength > 0) { using (var stream = new MemoryStream(data)) { Topic = MqString.FromStream(stream); if (Header.QualityOfService == QualityOfService.AtLeastOnce || Header.QualityOfService == QualityOfService.ExactlyOnce) { MessageId = MessageId.FromStream(stream); } Message = stream.Position < stream.Length ? stream.ReadRest() : new byte[0]; } } }