server ping

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-08-11 12:07:49 +02:00
parent 78e69338e7
commit 730be4e895
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0
2 changed files with 7 additions and 0 deletions

View File

@ -51,6 +51,11 @@ class Connection implements Storage {
this.handler(resp.result as Tx)
}
}
const interval = setInterval(() => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.sendRequest('ping')
}, 10000)
this.webSocket.onclose = () => { console.log('client websocket closed'); clearInterval(interval) }
}
private sendRequest (method: string, ...params: any[]): Promise<any> {

View File

@ -39,6 +39,8 @@ class Session implements Storage {
private readonly storage: ServerStorage
) {}
async ping (): Promise<string> { return 'pong!' }
async findAll <T extends Doc>(_class: Ref<Class<T>>, query: DocumentQuery<T>, options?: FindOptions<T>): Promise<FindResult<T>> {
return await this.storage.findAll(_class, query, options)
}