npm.io
1.0.5 • Published 5 years ago

@htblaleonie/leonie-mqtt

Licence
MIT
Version
1.0.5
Deps
1
Size
7 kB
Vulns
0
Weekly
0

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

  1. Increment the version in the package.json (we are using semantic versioning)
  2. Run npm publish


Copyright 2020 - 2021, Jonas Dorfinger. This package is MIT licensed