Skip to content
This repository has been archived by the owner on Aug 19, 2023. It is now read-only.

A Reactive Managed Client for MQTTnet Broker

License

Notifications You must be signed in to change notification settings

ChrisPulman/MQTTnet.Rx.ManagedClient

Repository files navigation

This repo has moved to https://github.com/ChrisPulman/MQTTnet.Rx

License Build Nuget NuGet

Alt

MQTTnet.Rx.ManagedClient

MQTTnet.Rx.ManagedClient

A Reactive Managed Client for MQTTnet Broker

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 Managed Mqtt Client to Publish an Observable stream

Create.ManagedMqttClient()
    .WithManagedClientOptions(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 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()}"));

Create a Managed Mqtt Client to Subscribe to a Topic

Create.ManagedMqttClient()
    .WithManagedClientOptions(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()}"));