npm.io
2.1.1 • Published 5 years ago

@haum/mqtt

Licence
MIT
Version
2.1.1
Deps
3
Size
4 kB
Vulns
0
Weekly
0

@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);