Skip to content

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

Notifications You must be signed in to change notification settings

hezhii/general-mqtt

Repository files navigation

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

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')
  },
})

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published