Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Mqtt js react-native

var mqtt = require('@taoqf/react-native-mqtt')
var client  = mqtt.connect('mqtt://test.mosquitto.org')
 
client.on('connect', function () {
  client.subscribe('presence', function (err) {
    if (!err) {
      client.publish('presence', 'Hello mqtt')
    }
  })
})
 
client.on('message', function (topic, message) {
  // message is Buffer
  console.log(message.toString())
  client.end()
})
Source by www.npmjs.com #
 
PREVIOUS NEXT
Tagged: #Mqtt #js
ADD COMMENT
Topic
Name
3+5 =