mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 11:10:11 +08:00
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:
1 parent
10e9d89349
commit
7d7ad154ab
10 files changed
+179
-168
No files matched your search
+12
-14
@@ -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
|
||||
Reference in new issue
Block a user