Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/hezhii/general-mqtt
- Owner: hezhii
- Created: 2020-05-07T01:40:19.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-04T08:39:00.000Z (almost 3 years ago)
- Last Synced: 2024-10-06T06:49:30.810Z (about 2 months ago)
- Language: TypeScript
- Homepage:
- Size: 491 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
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')
},
})
```