Skip to content

Latest commit

 

History

History
95 lines (76 loc) · 4.13 KB

README.md

File metadata and controls

95 lines (76 loc) · 4.13 KB

License Build

MQTTnet.Rx.Client

Nuget NuGet

MQTTnet.Rx.ABPlc

Nuget NuGet

MQTTnet.Rx.Modbus

Nuget NuGet

MQTTnet.Rx.S7Plc

Nuget NuGet

MQTTnet.Rx.SerialPort

Nuget NuGet

MQTTnet.Rx.TwinCAT

Nuget NuGet

Alt

MQTTnet.Rx

MQTTnet.Rx.Client

A Reactive Client for MQTTnet Broker

NOTE: ManagedClient support has been removed from the MQTTnet.Rx.Client library. This is due to the fact that the ManagedClient is no longer included in the MQTTnet V5 library.

We now have a Reactive implimentaion through IResilientClient that we aim to have feature parity with the ManagedClient.

The ResilientClient is a wrapper around the MqttClient that will automatically reconnect to the broker if the connection is lost.

Create a Resilient Mqtt Client to Publish an Observable stream

Create.ResilientMqttClient()
    .WithResilientClientOptions(a =>
    a.WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
        .WithClientOptions(c =>
            c.WithTcpServer("localhost", 9000)))
    .PublishMessage(_message)
    .Subscribe(r => Console.WriteLine($"{r.ReasonCode} [{r.PacketIdentifier}]"));

Create a Resilient Mqtt Client to Subscribe to a Topic

Create.ResilientMqttClient()
    .WithResilientClientOptions(a =>
        a.WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
            .WithClientOptions(c =>
                c.WithTcpServer("localhost", 9000)))
    .SubscribeToTopic("FromMilliseconds")
    .Subscribe(r => Console.WriteLine($"{r.ReasonCode} [{r.ApplicationMessage.Topic}] value : {r.ApplicationMessage.ConvertPayloadToString()}"));

Create a Mqtt Client to Publish an Observable stream

Create.MqttClient()
    .WithClientOptions(a => a.WithTcpServer("localhost", 9000))
    .PublishMessage(_message)
    .Subscribe(r => Console.WriteLine($"{r.ReasonCode} [{r.PacketIdentifier}]"));

Create a Mqtt Client to Subscribe to a Topic

Create.MqttClient()
    .WithClientOptions(a => a.WithTcpServer("localhost", 9000))
    .SubscribeToTopic("FromMilliseconds")
    .Subscribe(r => Console.WriteLine($"{r.ReasonCode} [{r.ApplicationMessage.Topic}] value : {r.ApplicationMessage.ConvertPayloadToString()}"));

MQTTnet.Rx.Server

A Reactive Server for MQTTnet Broker

Create a Mqtt Server

Create.MqttServer(builder =>
        builder
        .WithDefaultEndpointPort(2883)
        .WithDefaultEndpoint()
        .Build())
      .Subscribe();