general-mqtt
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

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

/general-mqtt/

    Package Sidebar

    Install

    npm i general-mqtt

    Weekly Downloads

    3

    Version

    1.1.2

    License

    MIT

    Unpacked Size

    123 kB

    Total Files

    27

    Last publish

    Collaborators

    • hezhou