From fe9a672a242db523eddb8b157796dc55e03ba35b Mon Sep 17 00:00:00 2001 From: bob-potter-sp <79337340+bob-potter-sp@users.noreply.github.com> Date: Wed, 26 Apr 2023 11:32:37 -0500 Subject: [PATCH] PLTCONN-3034: Add keepAlive method to Response --- lib/response/index.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/response/index.ts b/lib/response/index.ts index c832d08..0a2595e 100644 --- a/lib/response/index.ts +++ b/lib/response/index.ts @@ -8,6 +8,7 @@ import { Writable } from 'stream' export interface Response { send(output: T): void saveState(state: any): void + keepAlive(): void } /** @@ -35,6 +36,17 @@ export class ResponseStream implements Response { saveState(state: any): void { this._writable.write(new RawResponse(state, ResponseType.State)) } + + /** + * Indicates that the commands is still running. + * + * Can be used to avoid a timeout error in the case when a command + * is unable to return responses in a timely manner but is still + * actively processing the command. + */ + keepAlive(): void { + this._writable.write(new RawResponse({}, ResponseType.KeepAlive)) + } } /** @@ -42,7 +54,8 @@ export class ResponseStream implements Response { */ enum ResponseType { Output = 'output', - State = 'state' + State = 'state', + KeepAlive = 'keepAlive' } /**