forked from platypush/platypush
Fixed websocket reconnection logic
This commit is contained in:
parent
fc718c907a
commit
79179746a7
1 changed files with 10 additions and 8 deletions
|
@ -28,12 +28,12 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onWebsocketTimeout() {
|
onWebsocketTimeout() {
|
||||||
return function() {
|
console.log('Websocket reconnection timed out, retrying')
|
||||||
console.log('Websocket reconnection timed out, retrying')
|
this.pending = false
|
||||||
this.pending = false
|
if (this.ws)
|
||||||
this.close()
|
this.ws.close()
|
||||||
this.onclose()
|
|
||||||
}
|
this.onClose()
|
||||||
},
|
},
|
||||||
|
|
||||||
onMessage(event) {
|
onMessage(event) {
|
||||||
|
@ -74,8 +74,10 @@ export default {
|
||||||
onOpen() {
|
onOpen() {
|
||||||
if (this.opened) {
|
if (this.opened) {
|
||||||
console.log("There's already an opened websocket connection, closing the newly opened one")
|
console.log("There's already an opened websocket connection, closing the newly opened one")
|
||||||
this.onclose = () => {}
|
if (this.ws) {
|
||||||
this.close()
|
this.ws.onclose = () => {}
|
||||||
|
this.ws.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Websocket connection successful')
|
console.log('Websocket connection successful')
|
||||||
|
|
Loading…
Reference in a new issue