I developed the MQTT Dart library as I was working on the backend of a mobile app in 2013. The backend was developed in Dart but I could not find any MQTT library.
I’ve not been too active on the library recently due to lack of time. But I have plan to review the library with the latest Dart features and include the missing MQTT features before the end of the year.
Features
Feature
MQTT 3.1
MQTT 3.1.1
LWT
SSL/TLS
Automatic Reconnect
Feature
QoS 0
QoS 1
QoS 2
Authentication
Throttling
Usage
Installation
Add this to your package’s pubspec.yaml file:
1
2
dependencies:mqtt:"^1.1.0"
You can install packages from the command line:
1
$ pub get
In your dart code add:
1
import'package:mqtt/mqtt_shared.dart';
Connect
1.Define a connection
Before connecting to the broker you must define a connection. Web socket and socket connections are supported:
c.unsubscribe("MyTopic",s.messageID).then((u)=>print("Unsubscribed from subscription ${u.messageID}"));
Disconnect
1
c.disconnect();
About Jean-Noel Guillerme
I work as an independent software developer in London. I’ve been working on projects around messaging for more than 10 years. I started working with MQTT a couple of years ago, when I was involved in mobile app projects.
Subscribe to our newsletter for updates on HiveMQ, MQTT, and IoT.
By clicking the subscribe button, you give your consent to the use of your data according to our Privacy Policy.You can withdraw your consent at any time with future effect.
Like this post?
Get HiveMQ news delivered directly to your inbox
By clicking the subscribe button, you give your consent to the
use of your data according to our Privacy Policy. You can withdraw
your consent at any time with future effect.