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

0.1.7 • Public • Published

react-native-hi-mqtt

mqtt connect disconnect subscribe unsubscribe publish

Installation

npm install react-native-hi-mqtt

Usage

import * as Mqtt from "react-native-hi-mqtt";

// ...
let host = "192.168.4.106";
let port = 1883;
let clientId = "hiClient";
let ackType = 0;//AUTO_ACK|MANUAL_ACK
let topic = "/skyry/chat";
Mqtt.initClient(host, port, clientId, ackType);
Mqtt.connect({ username: '', password: '' });
Mqtt.disconnect();
Mqtt.subscribe(topic, 0);
Mqtt.unsubscribe(topic);
Mqtt.publish(topic, { qos: 0, payload: '' });
Mqtt.on('action',(event)=>{
  let {type,state,error} = event;
});
Mqtt.on('message',(event)=>{
  let {topic,message} = event;
});

  • 0.1.7 ios 增加自动重连

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Package Sidebar

Install

npm i react-native-hi-mqtt

Weekly Downloads

0

Version

0.1.7

License

MIT

Unpacked Size

78.6 kB

Total Files

22

Last publish

Collaborators

  • reylen