Fixed websocket reconnection logic

This commit is contained in:
Fabio Manganiello 2020-12-09 20:40:22 +01:00
parent fc718c907a
commit 79179746a7

View file

@ -28,12 +28,12 @@ export default {
methods: {
onWebsocketTimeout() {
return function() {
console.log('Websocket reconnection timed out, retrying')
this.pending = false
this.close()
this.onclose()
}
if (this.ws)
this.ws.close()
this.onClose()
},
onMessage(event) {
@ -74,8 +74,10 @@ export default {
onOpen() {
if (this.opened) {
console.log("There's already an opened websocket connection, closing the newly opened one")
this.onclose = () => {}
this.close()
if (this.ws) {
this.ws.onclose = () => {}
this.ws.close()
}
}
console.log('Websocket connection successful')