mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-11 12:17:44 +02:00
Ping from server (#5039)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -89,8 +89,6 @@ class Connection implements ClientConnection {
|
||||
readonly onConnect?: (event: ClientConnectEvent) => Promise<void>
|
||||
) {
|
||||
this.interval = setInterval(() => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
|
||||
if (this.pingResponse !== 0 && Date.now() - this.pingResponse > hangTimeout) {
|
||||
// No ping response from server.
|
||||
const s = this.websocket
|
||||
@@ -108,6 +106,7 @@ class Connection implements ClientConnection {
|
||||
this.websocket = null
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
void this.sendRequest({ method: 'ping', params: [] }).then(() => {
|
||||
this.pingResponse = Date.now()
|
||||
})
|
||||
@@ -229,6 +228,10 @@ class Connection implements ClientConnection {
|
||||
)
|
||||
return
|
||||
}
|
||||
if (resp.result === 'ping') {
|
||||
void this.sendRequest({ method: 'ping', params: [] })
|
||||
return
|
||||
}
|
||||
if (resp.id !== undefined) {
|
||||
const promise = this.requests.get(resp.id)
|
||||
if (promise === undefined) {
|
||||
|
||||
Reference in New Issue
Block a user