Fix re-login error (#60)

* refactor: put all session ref into one reactive store

* fix relogin duplicate signal

* fix: put quest data into store, fix hint reactivity

* fix: duplicate after relogin

* only register listener once
This commit is contained in:
Lin, Hung-Shin authored and GitHub committed 2023-11-08 14:22:08 +08:00
1 parent 10e9d89349
commit 7d7ad154ab
10 files changed
+179 -168

No files matched your search

+12 -14
View File
@@ -8,10 +8,7 @@ class SocketWrapper {
connect(session) {
return new Promise((resolve, reject) => {
if (this.socket) {
this.socket.off()
this.socket.disconnect()
}
this.disconnect()
this.socket = io('', {
query: {
@@ -38,25 +35,26 @@ class SocketWrapper {
}
}
once(event, callback) {
if (this.socket) {
this.socket.once(event, callback)
}
}
bindListeners() {
this.listeners.forEach(({ event, callback }) => {
this.socket.on(event, callback)
})
}
send(data) {
this.socket.send(data)
}
emit(event, data) {
this.socket.emit(event, data)
}
disconnect() {
if (this.socket) {
this.socket.off()
this.socket.disconnect()
}
}
reset() {
this.disconnect()
}
}
export default SocketWrapper