RxMQTTnet
4.3.56
Uma extensão do projeto MQTTNET, para transformar as assinaturas em observáveis e publicar em um fluxo observável.
Use o MQTTnet.MqttFactory com o MQTTnet.Extensions.External.RxMQTT.Client.MqttFactoryExtensions .
var client = new MqttFactory ( ) . CreateRxMqttClient ( ) ; Use as opções de cliente gerenciado
await client . StartAsync ( options ) . ConfigureAwait ( false ) ; Obtenha um IObservable<MqttApplicationMessageReceivedEventArgs> conectando -se ao cliente RX e use extensões para processar a mensagem:
var subscription = rxMqttClinet
. Connect ( "RxClientTest/#" )
. SelectPayload ( )
. Subscribe ( Console . WriteLine ) ;Termine a assinatura descartando a assinatura.
subscription . Dispose ( ) ; Crie uma sequência observável de MqttApplicationMessage s e publique -os através do cliente RX.
Observable . Interval ( TimeSpan . FromMilliseconds ( 1000 ) )
. Select ( i => new MqttApplicationMessageBuilder ( )
. WithTopic ( "RxClientTest" )
. WithPayload ( "Time: " + DateTime . Now . ToLongTimeString ( ) )
. WithQualityOfServiceLevel ( MqttQualityOfServiceLevel . ExactlyOnce )
. WithRetainFlag ( )
. Build ( ) )
. PublishOn ( mqttClient )
. Subscribe ( ) ; Use o método de publicação do cliente MQTT.