Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
15 lines (12 sloc) 375 Bytes
var mqtt = require('mqtt')
//var client = mqtt.connect('mqtt://test.mosquitto.org')
var client = mqtt.connect('mqtt://localhost:1883')
client.on('connect', function () {
client.subscribe('presence')
client.publish('presence', 'Hello mqtt')
})
client.on('message', function (topic, message) {
// message is Buffer
console.log(message.toString())
client.end()
})