通过如下判断无效,有没有其它有效方法?
if (this.client != null && (this.client.connected == true && this.client.disconnecting == false && (this.client.disconnected == undefined || this.client.disconnected == false))) {
// 连接状态
} else if (this.client == null || (this.client.connected == false || (this.client.disconnected == true && this.client.disconnecting == true))) {
// 断开连接状态
}
emqx dashboard 已经显示客户端未连接,但是 mqtt实例client的属性仍显示为{connected: true, disconnecting: false}