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

1.0.2 • Public • Published

LTGMQTTClient

  • 描述

    • 封装为单实例模式,全局只创建一个连接.
    • 处理了设备上下线,加入等消息.
    • 自动更新设备列表的状态.
  • 变量

    • deviceList:设备列表
    • client: 创建MQTT客户端的实例;
    • 订阅 分别是门店|设备类型|自身
      • shopTopic: 门店: /ltg/36/
      • typeTopic: 设备类型:/ltg/36/TVBox/
      • deviceTopic: 设备自身:/ltg/36/TVBox/SN
  • method

    • init:初始化并连接mqtt

      • @params:
        • host:string;主机
        • mqttOption:mqtt客户端配置
        • shopNumber,
        • type,
        • clientId,
        • model,
        • name,
        • groupId
    • public:发布消息

      • @params:
        • topic: string;订阅,名
        • message: string | Buffer;消息
        • responseTopic?: string;响应的订阅
        • contentType?: 'data' | 'join' | 'online' | 'offline';
    • subscribe:订阅

      • @params:
        • topic:string|string[]
        • Qos:0|1|2
    • getOnlineDeviceByType:获取指定类型的在线列表

      • @params:
        • type:string
    • on:订阅消息

      • @params
        • event:'message'|'error'|'disconnect'|'end'|'close'
        • callback:()=void
    • end:关闭连接

Readme

Keywords

none

Package Sidebar

Install

npm i ltg-mqtt

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

15.3 kB

Total Files

7

Last publish

Collaborators

  • conkyliu