Fix:Socket reconnection on disconnect, Add:Connection indicator icon showing socket/cellular

This commit is contained in:
advplyr 2022-07-07 17:24:26 -05:00
parent e07e7f70d6
commit cb2aaede67
7 changed files with 95 additions and 21 deletions

View file

@ -39,6 +39,7 @@ class ServerSocket extends EventEmitter {
logout() {
if (this.socket) this.socket.disconnect()
this.removeListeners()
}
setSocketListeners() {
@ -54,6 +55,14 @@ class ServerSocket extends EventEmitter {
// })
}
removeListeners() {
if (!this.socket) return
this.socket.removeAllListeners()
if (this.socket.io && this.socket.io.removeAllListeners) {
this.socket.io.removeAllListeners()
}
}
onConnect() {
console.log('[SOCKET] Socket Connected ' + this.socket.id)
this.connected = true
@ -67,11 +76,6 @@ class ServerSocket extends EventEmitter {
this.connected = false
this.$store.commit('setSocketConnected', false)
this.emit('connection-update', false)
this.socket.removeAllListeners()
if (this.socket.io && this.socket.io.removeAllListeners) {
this.socket.io.removeAllListeners()
}
}
onInit(data) {