mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 02:24:16 +00:00
Fix websocket restoration
This commit is contained in:
parent
8163056179
commit
d589168e73
@ -40,11 +40,15 @@ class ComtyApp extends React.Component {
|
||||
await this.auth.flush()
|
||||
await this.initialization()
|
||||
|
||||
app.cores.api.reset()
|
||||
|
||||
app.navigation.goMain()
|
||||
},
|
||||
onLogout: async () => {
|
||||
await this.auth.flush()
|
||||
|
||||
app.cores.api.reset()
|
||||
|
||||
app.navigation.goAuth()
|
||||
},
|
||||
onInvalidSession: async (error) => {
|
||||
|
@ -24,6 +24,7 @@ export default class APICore extends Core {
|
||||
listenEvent: this.listenEvent.bind(this),
|
||||
unlistenEvent: this.unlistenEvent.bind(this),
|
||||
emitEvent: this.emitEvent.bind(this),
|
||||
reset: this.reset.bind(this),
|
||||
measurePing: measurePing,
|
||||
useRequest: useRequest,
|
||||
}
|
||||
@ -84,6 +85,10 @@ export default class APICore extends Core {
|
||||
return this.client.ws.sockets.get(instance).off(key, handler)
|
||||
}
|
||||
|
||||
async reset() {
|
||||
this.client.ws.connectAll()
|
||||
}
|
||||
|
||||
async onInitialize() {
|
||||
this.client = await createClient({
|
||||
eventBus: app.eventBus,
|
||||
@ -93,15 +98,6 @@ export default class APICore extends Core {
|
||||
},
|
||||
})
|
||||
|
||||
// handle auth events
|
||||
this.client.eventBus.on("auth:login_success", () => {
|
||||
this.client.ws.connectAll()
|
||||
})
|
||||
|
||||
this.client.eventBus.on("auth:logout_success", () => {
|
||||
this.client.ws.connectAll()
|
||||
})
|
||||
|
||||
// make a basic request to check if the API is available
|
||||
await this.client
|
||||
.baseRequest({
|
||||
|
Loading…
x
Reference in New Issue
Block a user