1.0.5 • Published 3 years ago
@htblaleonie/leonie-mqtt v1.0.5
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-mqtt
Create 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:
token
topic
payload
callback(err)
Subscribe
client.subscribe(token, topic, (topic, message, err) => {
if (err) {
console.error(err);
} else {
console.log(message.toString());
}
});
Params:
token
topic
callback(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