|
1 |
| - |
2 |
| - |
3 | 1 | []()
|
4 | 2 |
|
5 |
| -## Description |
| 3 | +## Description |
6 | 4 |
|
7 | 5 | [react-native](https://github.com/facebook/react-native) mqtt client module
|
8 | 6 |
|
9 | 7 | ## MQTT Features (inherit from native MQTT framework)
|
10 | 8 | * Use [MQTT Framework](https://github.com/ckrey/MQTT-Client-Framework) for IOS, [Paho MQTT Client](https://eclipse.org/paho/clients/android/) for Android
|
11 | 9 | * Support both IOS and Android
|
12 |
| -* SSL/TLS |
13 |
| -* Native library, support mqtt over tcp |
| 10 | +* SSL/TLS |
| 11 | +* Native library, support mqtt over tcp |
14 | 12 |
|
15 | 13 | ## Warning
|
16 |
| -This library in progress developing, api may change, SSL/TLS non verify |
| 14 | +This library in progress developing, api may change, SSL/TLS non verify |
17 | 15 |
|
18 | 16 | ## Getting started
|
19 | 17 |
|
@@ -76,22 +74,20 @@ dependencies {
|
76 | 74 | ## Usage
|
77 | 75 |
|
78 | 76 | ```javascript
|
79 |
| -var mqtt = require('react-native-mqtt'); |
| 77 | +import MQTT from 'react-native-mqtt'; |
80 | 78 |
|
81 | 79 | /* create mqtt client */
|
82 |
| -mqtt.createClient({ |
83 |
| - uri: 'mqtt://test.mosquitto.org:1883', |
| 80 | +MQTT.createClient({ |
| 81 | + uri: 'mqtt://test.mosquitto.org:1883', |
84 | 82 | clientId: 'your_client_id'
|
85 | 83 | }).then(function(client) {
|
86 | 84 |
|
87 | 85 | client.on('closed', function() {
|
88 | 86 | console.log('mqtt.event.closed');
|
89 |
| - |
90 | 87 | });
|
91 |
| - |
| 88 | + |
92 | 89 | client.on('error', function(msg) {
|
93 | 90 | console.log('mqtt.event.error', msg);
|
94 |
| - |
95 | 91 | });
|
96 | 92 |
|
97 | 93 | client.on('message', function(msg) {
|
|
0 commit comments