0.1.0 • Published 8 years ago

wt-mqtt v0.1.0

Weekly downloads
4
License
ISC
Repository
github
Last release
8 years ago

MQTT Client

MQTT Client for the browser & React Native

This is an export of the MQTT.js library, but exported with Webpack as a CommonJS module for ease of use.

Installation

$ npm i --save wt-mqtt

Usage (ES6)

import mqtt from 'wt-mqtt'

...

var client = mqtt.connect('ws://localhost:3000')

client.subscribe('mqtt/demo')

client.on('connect', () => {
  console.log('mqtt connected')
})

client.on('message', (topic, payload) => {
  console.log([topic, payload].join(': '))
  client.end()
})

client.publish('mqtt/demo', 'hello world!')

Server

We use Mosca as our MQTT broker. Read this wiki for a guide of setting up Mosca over WebSockets.

0.1.0

8 years ago