SkillAgentSearch skills...

RxMQTTnet

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

Install / Use

/learn @mmuecke/RxMQTTnet
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

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.

Related Skills

View on GitHub
GitHub Stars30
CategoryDevelopment
Updated7mo ago
Forks7

Languages

C#

Security Score

87/100

Audited on Sep 8, 2025

No findings