Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Latest commit

 

History

History
31 lines (22 loc) · 603 Bytes

README.md

File metadata and controls

31 lines (22 loc) · 603 Bytes

MQTT client

MQTT client implementation for JavaScript

Installation

npm install --save @netology-group/mqtt-client

Example

const client = new MQTTClient('ws://iot.eclipse.org:80/ws')

client.connect()

client.on(MQTTClient.events.MESSAGE, function (topic, message) {
  console.log('[message]', topic, message.toString())
  client.disconnect()
})

client.on(MQTTClient.events.CONNECT, function (event) {
  client.subscribe('test/topic/1/#', null, function (err, data) {
    client.publish('test/topic/1/2/3', 'Hello, MQTT!')
  })
})

Documentation