mirror of
https://github.com/kerwincui/FastBee.git
synced 2025-10-15 12:42:19 +08:00
设备列表取消订阅
This commit is contained in:
@@ -392,12 +392,13 @@ export default {
|
|||||||
mqttSubscribe(list) {
|
mqttSubscribe(list) {
|
||||||
// 订阅当前页面设备状态和实时监测
|
// 订阅当前页面设备状态和实时监测
|
||||||
let topics = [];
|
let topics = [];
|
||||||
for (let i = 0; i < list.length; i++) {
|
// 订阅数太多,会导致emqx连接中断或者订阅缓慢
|
||||||
let topicStatus = "/" + list[i].productId + "/" + list[i].serialNumber + "/status/post";
|
// for (let i = 0; i < list.length; i++) {
|
||||||
let topicMonitor = "/" + list[i].productId + "/" + list[i].serialNumber + "/monitor/post";
|
// let topicStatus = "/" + list[i].productId + "/" + list[i].serialNumber + "/status/post";
|
||||||
topics.push(topicStatus);
|
// let topicMonitor = "/" + list[i].productId + "/" + list[i].serialNumber + "/monitor/post";
|
||||||
topics.push(topicMonitor);
|
// topics.push(topicStatus);
|
||||||
}
|
// topics.push(topicMonitor);
|
||||||
|
// }
|
||||||
this.subscribes = topics;
|
this.subscribes = topics;
|
||||||
},
|
},
|
||||||
/** 更新实时监测参数*/
|
/** 更新实时监测参数*/
|
||||||
|
@@ -30,8 +30,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {};
|
||||||
};
|
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
||||||
@@ -55,6 +54,7 @@ export default {
|
|||||||
this.client.on("connect", (e) => {
|
this.client.on("connect", (e) => {
|
||||||
console.log("成功连接服务器:", e);
|
console.log("成功连接服务器:", e);
|
||||||
// 订阅主题
|
// 订阅主题
|
||||||
|
if (subscribeTopics != '' && subscribeTopics.length > 0) {
|
||||||
this.client.subscribe(subscribeTopics, {
|
this.client.subscribe(subscribeTopics, {
|
||||||
qos: 1
|
qos: 1
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
@@ -65,6 +65,7 @@ export default {
|
|||||||
console.log('消息订阅失败!')
|
console.log('消息订阅失败!')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// 重新连接
|
// 重新连接
|
||||||
this.reconnectMqtt()
|
this.reconnectMqtt()
|
||||||
|
Reference in New Issue
Block a user