Skip to content

officialdoniald/Xamarin.MQTT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Xamarin.MQTT

NuGet Package: https://www.nuget.org/packages/Xamarin.MQTT/

Usage:

  1. I created two contructors of the MQTTConnection class. You can init this object with a specific MqttClientOptions and a string array of your topics, or with username, passowrd, a string array of your topics, servername, port and clientid.

https://github.com/officialdoniald/Xamarin.MQTT/blob/master/Xamarin.MQTT.Example/Xamarin.MQTT.Example/App.xaml.cs

I created in the App.cs a static variable of the MQTTConnection class, so I can reach this object anywhere.

  1. You have to connect to the MQTT server:

await App.MqttConnection.CreateMQTTConnection();

  1. You can subscribe to the MQTTConnection events:

MqttConnection.OnConnected += MqttConnection_OnConnected;

MqttConnection.OnDisconnected += MqttConnection_OnDisconnected;

MqttConnection.OnErrorAtSending += MqttConnection_OnErrorAtSending;

MqttConnection.OnMessageReceived += MqttConnection_OnMessageReceived;

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages