Guest User

Untitled

a guest
Apr 7th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. var mqtt = require('mqtt');
  2. var options = {
  3. username: 'try',
  4. password: 'try'
  5. }
  6. var client = mqtt.connect('mqtt://broker.shiftr.io', options);
  7.  
  8. client.on('connect', function() {
  9. client.subscribe("thebestpets");
  10. client.publish("thebestpets/dogs", "Dogs are really great");
  11. })
  12.  
  13. client.on("message", function (topic, message) {
  14. console.log(message.toString())
  15. })
Add Comment
Please, Sign In to add comment