Browse Source
Merge pull request #348 from leirensheng/fix/socket
fix/socketCloseAlert
master
Dushusir
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
12 additions and
8 deletions
-
src/controllers/server.js
-
src/global/api.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{ |
|
|
|
|
|
@ -6291,8 +6291,7 @@ export function closeWebsocket(){ |
|
|
|
if(server.websocket == null){ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
server.websocket.close(); |
|
|
|
server.websocket.close(1000); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|