|
@@ -705,6 +705,7 @@ export default {
|
|
|
let self = this;
|
|
|
if(val.id != this.checkedSubject.id){
|
|
|
this.videoOff();
|
|
|
+ this.offMQTT();
|
|
|
this.subjectInfo(val.id);
|
|
|
this.subId = val.id;
|
|
|
this.$set(this,'queryParamsTwo',{
|
|
@@ -713,6 +714,7 @@ export default {
|
|
|
});
|
|
|
this.getEnablelist();
|
|
|
this.getHxpAlarmRecordNoAuthList();
|
|
|
+ this.subscriptionMQTT();
|
|
|
}
|
|
|
},
|
|
|
//获取实验室详情
|
|
@@ -801,7 +803,7 @@ export default {
|
|
|
/** 查询实验室列表 */
|
|
|
getList() {
|
|
|
this.loading = true;
|
|
|
- this.offMQTT();
|
|
|
+ // this.offMQTT();
|
|
|
authListSubject(this.queryParams).then(response => {
|
|
|
this.subjectList = response.rows;
|
|
|
this.total = response.total;
|
|
@@ -815,7 +817,7 @@ export default {
|
|
|
idList.push(response.rows[i].id)
|
|
|
}
|
|
|
this.$set(this,'mqttIdList',idList);
|
|
|
- this.subscriptionMQTT();
|
|
|
+ // this.subscriptionMQTT();
|
|
|
});
|
|
|
},
|
|
|
/** 查询学院列表 */
|
|
@@ -833,18 +835,28 @@ export default {
|
|
|
});
|
|
|
this.client.on("connect", e =>{
|
|
|
console.log("连接成功");
|
|
|
- for(let i = 0; i< self.mqttIdList.length;i++){
|
|
|
- this.client.subscribe(this.mtopic+self.mqttIdList[i], (err) => {
|
|
|
- if (!err) {
|
|
|
- console.log("订阅成功:" + this.mtopic+self.mqttIdList[i]);
|
|
|
- }
|
|
|
- });
|
|
|
- this.client.subscribe(this.mtopicOne+self.mqttIdList[i], (err) => {
|
|
|
- if (!err) {
|
|
|
- console.log("订阅成功:" + this.mtopicOne+self.mqttIdList[i]);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ this.client.subscribe(this.mtopic+self.subId, (err) => {
|
|
|
+ if (!err) {
|
|
|
+ console.log("订阅成功:" + this.mtopic+self.subId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.client.subscribe(this.mtopicOne+self.subId, (err) => {
|
|
|
+ if (!err) {
|
|
|
+ console.log("订阅成功:" + this.mtopicOne+self.subId);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // for(let i = 0; i< self.mqttIdList.length;i++){
|
|
|
+ // this.client.subscribe(this.mtopic+self.mqttIdList[i], (err) => {
|
|
|
+ // if (!err) {
|
|
|
+ // console.log("订阅成功:" + this.mtopic+self.mqttIdList[i]);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // this.client.subscribe(this.mtopicOne+self.mqttIdList[i], (err) => {
|
|
|
+ // if (!err) {
|
|
|
+ // console.log("订阅成功:" + this.mtopicOne+self.mqttIdList[i]);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
});
|
|
|
this.client.on("message", (topic, message) => {
|
|
|
console.log('message',message)
|
|
@@ -905,18 +917,28 @@ export default {
|
|
|
offMQTT(){
|
|
|
let self = this;
|
|
|
if (self.mqttIdList[0]){
|
|
|
- for(let i=0;i<self.mqttIdList.length;i++){
|
|
|
- self.client.unsubscribe(self.mtopic+self.mqttIdList[i], error => {
|
|
|
- if (error) {
|
|
|
- console.log('Unsubscribe error', error)
|
|
|
- }
|
|
|
- })
|
|
|
- self.client.unsubscribe(self.mtopicOne+self.mqttIdList[i], error => {
|
|
|
- if (error) {
|
|
|
- console.log('Unsubscribe error', error)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ // for(let i=0;i<self.mqttIdList.length;i++){
|
|
|
+ // self.client.unsubscribe(self.mtopic+self.mqttIdList[i], error => {
|
|
|
+ // if (error) {
|
|
|
+ // console.log('Unsubscribe error', error)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // self.client.unsubscribe(self.mtopicOne+self.mqttIdList[i], error => {
|
|
|
+ // if (error) {
|
|
|
+ // console.log('Unsubscribe error', error)
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ self.client.unsubscribe(self.mtopic+self.subId, error => {
|
|
|
+ if (error) {
|
|
|
+ console.log('Unsubscribe error', error)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ self.client.unsubscribe(self.mtopicOne+self.subId, error => {
|
|
|
+ if (error) {
|
|
|
+ console.log('Unsubscribe error', error)
|
|
|
+ }
|
|
|
+ })
|
|
|
self.client.end();
|
|
|
self.client = {};
|
|
|
}
|