@htblaleonie/leonie-mqtt
v1.0.5
Published
Leonie Mqtt Client to send and receive Mqtt messages easier
Downloads
6
Readme
leonie-mqtt
The Leonie MQTT-Client. It has a type safe API for sending and receiving MQTT messages easier.
Usage
Install
npm i @htblaleonie/leonie-mqttCreate instance
import MqttClient from '@htblaleonie/leonie-mqtt';
const client = new MqttClient(config.mqttUrl);Publish
client.publish(token, topic, payload, err => {
if (err) {
console.error(err);
}
});Params:
tokentopicpayloadcallback(err)
Subscribe
client.subscribe(token, topic, (topic, message, err) => {
if (err) {
console.error(err);
} else {
console.log(message.toString());
}
});Params:
tokentopiccallback(topic, message, err)
Building and publishing
To easily make this code available to other teams, it's being published on npm. Effectively, this means that everything in this folder is public!
To publish a new version on npm
- Increment the version in the
package.json(we are using semantic versioning) - Run
npm publish
Copyright © 2020 - 2021, Jonas Dorfinger. This package is MIT licensed
