优化代码

This commit is contained in:
java110 2021-10-12 14:31:23 +08:00
parent 6823927d6e
commit fa7dbd793f

View File

@ -27,6 +27,7 @@
})
},
_initParkingAreaWs:function(){
let clientId = vc.uuid();
let heartCheck = {
timeout: 30000, // 9分钟发一次心跳比server端设置的连接时间稍微小一点在接近断开的情况下以通信的方式去重置连接时间。
serverTimeoutObj: null,
@ -51,7 +52,7 @@
heartCheck.reset().start(); // 如果获取到消息,说明连接是正常的,重置心跳检测
} else {
console.log("断开状态,尝试重连");
newWebSocket();
$that._initParkingAreaWs();
}
}, this.timeout)
}
@ -114,7 +115,7 @@
//连接关闭的回调方法
websocket.onclose = function () {
console.log("初始化失败");
//newWebSocket();
//$that._initParkingAreaWs();
this.$notify.error({
title: "错误",
message: "连接关闭,请刷新浏览器"