【类 型】: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链接成功 在线
|
store.state.app.mqttState = true // 标记mqtt链接成功 在线
|
||||||
// 订阅一个主题
|
// 订阅一个主题
|
||||||
this.client.subscribe(topic, { qos: 2 }, err => {
|
this.client.subscribe(topic, { qos: 2 })
|
||||||
if (!err) {
|
|
||||||
store.dispatch('fetchLog', { content: topic + '主题订阅成功' })
|
|
||||||
} else {
|
|
||||||
store.dispatch('fetchLog', { content: topic + '主题订阅失败' })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
// 获取订阅主题的消息
|
// 获取订阅主题的消息
|
||||||
this.client.on('message', (topic, message) => {
|
this.client.on('message', (topic, message) => {
|
||||||
|
@ -76,6 +76,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
airList (res) {
|
airList (res) {
|
||||||
/* mqtt */
|
/* mqtt */
|
||||||
|
mqtt.mqttDestroy()// 先断开mqtt
|
||||||
mqtt.mqttConf()// 连接mqtt
|
mqtt.mqttConf()// 连接mqtt
|
||||||
// 订阅飞机信息
|
// 订阅飞机信息
|
||||||
mqtt.doSubscribe('planeState/+', (mqttRes) => {
|
mqtt.doSubscribe('planeState/+', (mqttRes) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user