Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hezhii/general-mqtt

A general mqtt client that can be used in Wechat mini program, web, react native. It also encapsulates some common functions.
https://github.com/hezhii/general-mqtt

Last synced: 8 days ago
JSON representation

A general mqtt client that can be used in Wechat mini program, web, react native. It also encapsulates some common functions.

Awesome Lists containing this project

README

        

# general-mqtt

A general mqtt client that can be used in Wechat mini program, web, react native. It also encapsulates some common functions.

## Usage

### singleton

```js
ConnectionManager.initConnectionOptions({
debug: true,
uri: '',
clientId: '',
env: 'web',
userName: '',
password: '',
reconnect: true,
timeout: 5,
cleanSession: true,
maxReconnectTimeInterval: 32,
})

const conn = await ConnectionManager.sharedInstance()

conn.subscribe('/test', (topic, msg) => console.log(topic, msg), {
onSuccess() {
conn.publish('/test', 'hello world')
},
})
```