Browse Source

fix: 修复主动关闭socket定时器仍运行问题

master
leirensheng 5 years ago
parent
commit
82a8731934
  1. 10
      src/controllers/server.js

10
src/controllers/server.js

@ -25,7 +25,8 @@ const server = {
updateUrl: null,
updateImageUrl: null,
title: null,
loadSheetUrl: null,
loadSheetUrl: null,
retryTimer:null,
allowUpdate: false, //共享编辑模式
historyParam: function(data, sheetIndex, range) {
let _this = this;
@ -162,7 +163,7 @@ const server = {
_this.wxErrorCount = 0;
//防止websocket长时间不发送消息导致断连
setInterval(function(){
_this.retryTimer = setInterval(function(){
_this.websocket.send("rub");
}, 60000);
}
@ -322,7 +323,10 @@ const server = {
//连接关闭时触发
_this.websocket.onclose = function(e){
console.info(locale().websocket.close);
if(e.code!==1000){
if(e.code === 1000){
clearInterval(_this.retryTimer)
_this.retryTimer = null
}else{
alert(locale().websocket.contact);
}
}

Loading…
Cancel
Save