@openrc/react-native-mqtt
TypeScript icon, indicating that this package has built-in type declarations

3.0.8 • Public • Published

简体中文    

A minimalist MQTT library that supports react-native, keeps MQTT in sync, and supports Emq and mosquitto

Installation

npm i --save @openrc/react-native-mqtt
yarn add @openrc/react-native-mqtt

Example(websocket)

import MQTT from '@openrc/react-native-mqtt';

const client = MQTT.connect('ws://car.openrc.top/mqtt', {
  port: 8083,
  protocol: 'ws',
  username: 'your username',
  password: 'your password',
  reconnectPeriod: 30 * 1000,
  qos: 2,
});

client.on('closed', function () {
  console.log('mqtt event closed');
});

client.on('error', function (msg) {
  console.log('mqtt event error', msg);
});

client.on('connect', function () {
  console.log('connected mqtt');
});

export default client;

API

Learn more

License

MIT

Package Sidebar

Install

npm i @openrc/react-native-mqtt

Weekly Downloads

22

Version

3.0.8

License

MIT

Unpacked Size

411 kB

Total Files

68

Last publish

Collaborators

  • openrc