Beispiel #1
0
        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);
        }
Beispiel #2
0
        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]));
                        }
                    }
                }
            }
        }
Beispiel #3
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));
                        }
                    }
                }
            }
        }
Beispiel #4
0
        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);
            }
        }
Beispiel #5
0
        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];
                }
            }
        }