|
@@ -144,6 +144,7 @@ export default {
|
144
|
144
|
Object.keys(this.websockets).forEach((key) => {
|
145
|
145
|
console.log(key, this.websockets[key])
|
146
|
146
|
this.websockets[key].close()
|
|
147
|
+ clearInterval(this.websockets[key].interval)
|
147
|
148
|
})
|
148
|
149
|
this.websockets = {}
|
149
|
150
|
next()
|
|
@@ -312,11 +313,14 @@ export default {
|
312
|
313
|
this.websockets[wsRealPath].onopen = console.log
|
313
|
314
|
this.websockets[wsRealPath].onmessage = this.websocketonmessage
|
314
|
315
|
this.websockets[wsRealPath].onclose = this.reloadWebSocket
|
315
|
|
- setInterval(() => this.websockets[wsRealPath].send(10), 120000)
|
|
316
|
+ this.websockets[wsRealPath].interval = setInterval(() => this.websockets[wsRealPath].send(10), 120000)
|
316
|
317
|
}
|
317
|
318
|
},
|
318
|
319
|
reloadWebSocket (e) {
|
319
|
320
|
console.log(e.currentTarget.url)
|
|
321
|
+ Object.keys(this.websockets).forEach((key) => {
|
|
322
|
+ clearInterval(this.websockets[key].interval)
|
|
323
|
+ })
|
320
|
324
|
if (this.needReload) { // 此变量判断是否需要重连
|
321
|
325
|
this.websockets = {}
|
322
|
326
|
this.initWebSocket()
|