【类 型】:fix 刷新操作时 触发订多次订阅
【原 因】:watch时 飞机列表每次都重新连 重新订阅 导致订阅多次 【过 程】:断开 重连mqtt 【影 响】:
This commit is contained in:
parent
e273ba9951
commit
99cc2c193a
@ -54,13 +54,7 @@ function doSubscribe (topic, callBack) {
|
||||
}
|
||||
store.state.app.mqttState = true // 标记mqtt链接成功 在线
|
||||
// 订阅一个主题
|
||||
this.client.subscribe(topic, { qos: 2 }, err => {
|
||||
if (!err) {
|
||||
store.dispatch('fetchLog', { content: topic + '主题订阅成功' })
|
||||
} else {
|
||||
store.dispatch('fetchLog', { content: topic + '主题订阅失败' })
|
||||
}
|
||||
})
|
||||
this.client.subscribe(topic, { qos: 2 })
|
||||
})
|
||||
// 获取订阅主题的消息
|
||||
this.client.on('message', (topic, message) => {
|
||||
|
@ -76,6 +76,7 @@ export default {
|
||||
*/
|
||||
airList (res) {
|
||||
/* mqtt */
|
||||
mqtt.mqttDestroy()// 先断开mqtt
|
||||
mqtt.mqttConf()// 连接mqtt
|
||||
// 订阅飞机信息
|
||||
mqtt.doSubscribe('planeState/+', (mqttRes) => {
|
||||
|
Loading…
Reference in New Issue
Block a user