Created
April 27, 2018 10:57
-
-
Save cbh6/0bc0d1febc76c0ed0c3d6cccd624db0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mqtt = require('mqtt') | |
var client = mqtt.connect('mqtt://test.mosquitto.org') | |
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() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment