Пример #1
0
        internal static ConnectFlags FromStream(Stream stream)
        {
            byte b = stream.ReadBytesOrFailAsync(1).Await().Result[0];
            var flags = new ConnectFlags
                {
                    UserName = (b & 0x80) == 0x80,
                    Password = (b & 0x40) == 0x40,
                    WillRetain = (b & 0x20) == 0x20,
                    WillQoS = (QualityOfService) ((b & 0x18) >> 3),
                    Will = (b & 0x04) == 0x04,
                    CleanSession = (b & 0x02) == 0x02
                };

            return flags;
        }
Пример #2
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;
        }
Пример #3
0
 public static string FromStream(Stream data)
 {
     var length = data.ReadUint16();
     return Encoding.UTF8.GetString(data.ReadBytesOrFailAsync(length).Await().Result);
 }