mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-22 19:11:33 +03:00
UBERF-8280: Ping properly from server (#6733)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
28fffa883f
commit
cc67c2792e
@ -57,6 +57,8 @@ export class ClientSession implements Session {
|
||||
sessionId = ''
|
||||
lastRequest = Date.now()
|
||||
|
||||
lastPing: number = Date.now()
|
||||
|
||||
total: StatisticsElement = { find: 0, tx: 0 }
|
||||
current: StatisticsElement = { find: 0, tx: 0 }
|
||||
mins5: StatisticsElement = { find: 0, tx: 0 }
|
||||
|
@ -198,8 +198,13 @@ class TSessionManager implements SessionManager {
|
||||
void this.close(this.ctx, s[1].socket, wsId)
|
||||
continue
|
||||
}
|
||||
if (lastRequestDiff + (1 / 10) * lastRequestDiff > this.timeouts.pingTimeout) {
|
||||
if (
|
||||
lastRequestDiff + (1 / 10) * lastRequestDiff > this.timeouts.pingTimeout &&
|
||||
now - s[1].session.lastPing > this.timeouts.pingTimeout
|
||||
) {
|
||||
// We need to check state and close socket if it broken
|
||||
// And ping other wize
|
||||
s[1].session.lastPing = now
|
||||
if (s[1].socket.checkState()) {
|
||||
s[1].socket.send(
|
||||
workspace.context,
|
||||
|
@ -74,6 +74,7 @@ export interface Session {
|
||||
mins5: StatisticsElement
|
||||
|
||||
lastRequest: number
|
||||
lastPing: number
|
||||
|
||||
isUpgradeClient: () => boolean
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user