Browse Source

Merge pull request #348 from leirensheng/fix/socket

fix/socketCloseAlert
master
Dushusir 5 years ago
committed by GitHub
parent
commit
a0de4c1f45
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      src/controllers/server.js
  2. 3
      src/global/api.js

17
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);
}
@ -320,10 +321,14 @@ const server = {
}
//连接关闭时触发
_this.websocket.onclose = function(){
console.info(locale().websocket.close);
alert(locale().websocket.contact);
_this.websocket.onclose = function(e){
console.info(locale().websocket.close);
if(e.code === 1000){
clearInterval(_this.retryTimer)
_this.retryTimer = null
}else{
alert(locale().websocket.contact);
}
}
}
else{

3
src/global/api.js

@ -6291,8 +6291,7 @@ export function closeWebsocket(){
if(server.websocket == null){
return;
}
server.websocket.close();
server.websocket.close(1000);
}

Loading…
Cancel
Save