1.0.10 • Published 2 years ago

dolphin-mq v1.0.10

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@baifendian/dolp

该模块属于 DOLPHIN 协议的顶层API调用,基于 mqtt 开发,基本一致。

Installation

npm install @baifendian/dolp --save

Example

For the sake of simplicity, let's put the subscriber and the publisher in the same file:

var mqtt = require('@baifendian/dolp')
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()
})