<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [tsl-mqtt mqtt 客户端](#tsl-mqtt-mqtt-%E5%AE%A2%E6%88%B7%E7%AB%AF)
  - [1.使用](#1%E4%BD%BF%E7%94%A8)
  - [2.参数](#2%E5%8F%82%E6%95%B0)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# tsl-mqtt mqtt 客户端

全局维持一个 mqtt 单一实例，基于 mqtt.js

## 1.使用
```
// 初始化
let mqttClient = new TslMqttClient()
mqttClient.connectMqtt(url,option)

// 后续使用无须再调用 connectMqtt
// 可以直接
let mqtt = TslMqttClient.getInstance()
mqtt.subscribe(topic) topic 可以是 string 也可以是[]
mqtt.onMessage(function(topic, data){})
mqtt.unsubscribe(topic)
mqtt.publish(topic, message, options, callback)
mqtt.end() end 后不能再重新连接，注意！！！

```
## 2.参数

```
连接option
{
      username: mqttConfig.username,
      password: mqttConfig.password
}

```
