Add client configurable timeouts

This commit is contained in:
Andrey Sobolev
2025-09-30 13:42:02 +07:00
parent 4a42425301
commit 5d7ed6a4ff
7 changed files with 88 additions and 14 deletions
+4 -2
View File
@@ -98,9 +98,11 @@ export class NetworkClientImpl implements NetworkClient {
constructor (
readonly host: string,
port: number,
private readonly tickMgr: TickManager
private readonly tickMgr: TickManager,
aliveTimeout?: number
) {
this.client = new BackRPCClient<ClientUuid>(this.clientId, this, host, port, tickMgr)
const options = undefined
this.client = new BackRPCClient<ClientUuid>(this.clientId, this, host, port, tickMgr, options, aliveTimeout)
}
async waitConnection (timeout?: number): Promise<void> {
+2 -2
View File
@@ -26,11 +26,11 @@ process.on('exit', () => {
shutdownNetworkTickMgr()
})
export function createNetworkClient (url: string): NetworkClient {
export function createNetworkClient (url: string, aliveTimeout?: number): NetworkClient {
const [host, portStr] = url.split(':')
const port = portStr != null ? parseInt(portStr, 10) : 3737
tickMgr.start()
return new NetworkClientImpl(host, port, tickMgr)
return new NetworkClientImpl(host, port, tickMgr, aliveTimeout)
}
export async function createAgent (