mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +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.auth.flush()
|
||||||
await this.initialization()
|
await this.initialization()
|
||||||
|
|
||||||
|
app.cores.api.reset()
|
||||||
|
|
||||||
app.navigation.goMain()
|
app.navigation.goMain()
|
||||||
},
|
},
|
||||||
onLogout: async () => {
|
onLogout: async () => {
|
||||||
await this.auth.flush()
|
await this.auth.flush()
|
||||||
|
|
||||||
|
app.cores.api.reset()
|
||||||
|
|
||||||
app.navigation.goAuth()
|
app.navigation.goAuth()
|
||||||
},
|
},
|
||||||
onInvalidSession: async (error) => {
|
onInvalidSession: async (error) => {
|
||||||
|
@ -24,6 +24,7 @@ export default class APICore extends Core {
|
|||||||
listenEvent: this.listenEvent.bind(this),
|
listenEvent: this.listenEvent.bind(this),
|
||||||
unlistenEvent: this.unlistenEvent.bind(this),
|
unlistenEvent: this.unlistenEvent.bind(this),
|
||||||
emitEvent: this.emitEvent.bind(this),
|
emitEvent: this.emitEvent.bind(this),
|
||||||
|
reset: this.reset.bind(this),
|
||||||
measurePing: measurePing,
|
measurePing: measurePing,
|
||||||
useRequest: useRequest,
|
useRequest: useRequest,
|
||||||
}
|
}
|
||||||
@ -84,6 +85,10 @@ export default class APICore extends Core {
|
|||||||
return this.client.ws.sockets.get(instance).off(key, handler)
|
return this.client.ws.sockets.get(instance).off(key, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async reset() {
|
||||||
|
this.client.ws.connectAll()
|
||||||
|
}
|
||||||
|
|
||||||
async onInitialize() {
|
async onInitialize() {
|
||||||
this.client = await createClient({
|
this.client = await createClient({
|
||||||
eventBus: app.eventBus,
|
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
|
// make a basic request to check if the API is available
|
||||||
await this.client
|
await this.client
|
||||||
.baseRequest({
|
.baseRequest({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user