Skip to content

A extension to the MQTTnet project, to transform the subscriptions into observables and to publish form a observalbe stream.

License

Notifications You must be signed in to change notification settings

mmuecke/RxMQTTnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build codecov NuGet Stats Downloads

RxMQTTnet

An extension to the MQTTnet project, to transform the subscriptions into observables and to publish from an observable stream.

Create a client

Use the factory

Use the MQTTnet.MqttFactory with the MQTTnet.Extensions.External.RxMQTT.Client.MqttFactoryExtensions.

var client = new MqttFactory().CreateRxMqttClient();

Create the options

Use the managed client options

Start the client

await client.StartAsync(options).ConfigureAwait(false);

Subscribe

Get an IObservable<MqttApplicationMessageReceivedEventArgs> by connecting to the rx client and use extensions to process the message:

var subscription = rxMqttClinet
    .Connect("RxClientTest/#")
    .SelectPayload()
    .Subscribe(Console.WriteLine);

End the subscription by disposing the subscription.

subscription.Dispose();

Publish

From observable

Create an observable sequence of MqttApplicationMessages and publish these via the rx client.

Observable.Interval(TimeSpan.FromMilliseconds(1000))
    .Select(i => new MqttApplicationMessageBuilder()
        .WithTopic("RxClientTest")
        .WithPayload("Time: " + DateTime.Now.ToLongTimeString())
        .WithQualityOfServiceLevel(MqttQualityOfServiceLevel.ExactlyOnce)
        .WithRetainFlag()
        .Build())
    .PublishOn(mqttClient)
    .Subscribe();

Single message

Use the mqtt client publish method.

About

A extension to the MQTTnet project, to transform the subscriptions into observables and to publish form a observalbe stream.

Topics

Resources

License

Stars

Watchers

Forks

Languages