mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-30 21:45:01 +02:00
UBERF-8899: Reconnect performance issues (#7611)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -44,6 +44,7 @@ import core, {
|
||||
TxApplyIf,
|
||||
TxHandler,
|
||||
TxResult,
|
||||
clone,
|
||||
generateId,
|
||||
toFindResult,
|
||||
type MeasureContext
|
||||
@@ -108,6 +109,8 @@ class Connection implements ClientConnection {
|
||||
|
||||
private helloRecieved: boolean = false
|
||||
|
||||
private account: Account | undefined
|
||||
|
||||
onConnect?: (event: ClientConnectEvent, lastTx: string | undefined, data: any) => Promise<void>
|
||||
|
||||
rpcHandler = new RPCHandler()
|
||||
@@ -303,7 +306,7 @@ class Connection implements ClientConnection {
|
||||
this.websocket?.close()
|
||||
return
|
||||
}
|
||||
|
||||
this.account = helloResp.account
|
||||
this.helloRecieved = true
|
||||
if (this.upgrading) {
|
||||
// We need to call upgrade since connection is upgraded
|
||||
@@ -322,8 +325,8 @@ class Connection implements ClientConnection {
|
||||
}
|
||||
|
||||
void this.onConnect?.(
|
||||
(resp as HelloResponse).reconnect === true ? ClientConnectEvent.Reconnected : ClientConnectEvent.Connected,
|
||||
(resp as HelloResponse).lastTx,
|
||||
helloResp.reconnect === true ? ClientConnectEvent.Reconnected : ClientConnectEvent.Connected,
|
||||
helloResp.lastTx,
|
||||
this.sessionId
|
||||
)
|
||||
this.schedulePing(socketId)
|
||||
@@ -635,6 +638,9 @@ class Connection implements ClientConnection {
|
||||
}
|
||||
|
||||
getAccount (): Promise<Account> {
|
||||
if (this.account !== undefined) {
|
||||
return clone(this.account)
|
||||
}
|
||||
return this.sendRequest({ method: 'getAccount', params: [] })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user