2.1.1 • Published 3 years ago
@haum/mqtt v2.1.1
@haum/mqtt
Example
// Connect to mqtt://localhost:1883 as "usr" with password "pwd"
const mqtt = require('.')({
url: 'mqtt://localhost:1883',
auth: {
username: 'usr',
password: 'pwd'
}
});
// Subscribe to foo
let sub = mqtt.sub('foo', (topic, payload) => {
console.log(topic, payload)
});
// Publish bar to foo
mqtt.pub('foo', 'bar');
// Unsubscribe from foo
mqtt.unsub(sub);