Ejemplo n.º 1
0
        async Task <MqttConnAckPacket> Authenticate(ILowLevelMqttClient client)
        {
            await client.SendAsync(new MqttConnectPacket
            {
                CleanSession = true,
                ClientId     = TestContext.TestName,
                Username     = "******",
                Password     = Encoding.UTF8.GetBytes("pass")
            },
                                   CancellationToken.None).ConfigureAwait(false);

            return(await client.ReceiveAsync(CancellationToken.None).ConfigureAwait(false) as MqttConnAckPacket);
        }
Ejemplo n.º 2
0
        async Task <MqttSubAckPacket> Subscribe(ILowLevelMqttClient client, string topic)
        {
            await client.SendAsync(new MqttSubscribePacket
            {
                PacketIdentifier = 1,
                TopicFilters     = new List <MqttTopicFilter>
                {
                    new MqttTopicFilter
                    {
                        Topic = topic
                    }
                }
            },
                                   CancellationToken.None).ConfigureAwait(false);

            return(await client.ReceiveAsync(CancellationToken.None).ConfigureAwait(false) as MqttSubAckPacket);
        }