OpenNETCF MQTT Updated to .NET Standard

I’ve refactored the OpenNETCF MQTT library, which is a simple MQTT Client, to ne a .NET Standard 1.3 Library.  I also added a few async methods to bring it a little more up-to-date.

Source is in GitHub
Library is available via NuGet (as package ID ‘OpenNETCF.MQTT’)

Here’s a test method that generally shows how it can be used:

    public void ClientReceiveTest()
        var receivedMessage = false;

        // create the client
        var client = new MQTTClient("", 1883);

        // hook up the MessageReceived event with a handler
        client.MessageReceived += (topic, qos, payload) =>
            Debug.WriteLine("RX: " + topic);
            receivedMessage = true;

        var i = 0;
        // connect to the MQTT server
        // wait for the connection to complete
        while (!client.IsConnected)

            if (i++ > 10) Assert.Fail();


        // add a subscription
        client.Subscriptions.Add(new Subscription("OpenNETCF/#"));

        i = 0;
        while (true)
            if (receivedMessage) break;


            // publish on our own subscribed topic to see if we hear what we send
            client.Publish("OpenNETCF/Test", "Hello", QoS.FireAndForget, false);

            if (i++ > 10) break;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s