From: Jérôme Benoit Date: Fri, 26 May 2023 13:07:53 +0000 (+0200) Subject: fix: fix undefined payload check in UI server code X-Git-Tag: v1.2.14~2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=bf4afa568a47cf088c01725737aecb4be7df40b2;p=e-mobility-charging-stations-simulator.git fix: fix undefined payload check in UI server code Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index a1ee4ff2..5e1ac3eb 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -129,7 +129,7 @@ export class Bootstrap extends EventEmitter { public async stop(): Promise { if (isMainThread && this.started === true) { - await this.uiServer?.sendBroadcastChannelRequest( + await this.uiServer?.sendRequestOnBroadcastChannel( this.uiServer.buildProtocolRequest( Utils.generateUUID(), ProcedureName.STOP_CHARGING_STATION, diff --git a/src/charging-station/ui-server/AbstractUIServer.ts b/src/charging-station/ui-server/AbstractUIServer.ts index af5c0129..8552a572 100644 --- a/src/charging-station/ui-server/AbstractUIServer.ts +++ b/src/charging-station/ui-server/AbstractUIServer.ts @@ -46,7 +46,7 @@ export abstract class AbstractUIServer { this.chargingStations.clear(); } - public async sendBroadcastChannelRequest(request: ProtocolRequest): Promise { + public async sendRequestOnBroadcastChannel(request: ProtocolRequest): Promise { const protocolVersion = ProtocolVersion['0.0.1']; this.registerProtocolVersionUIService(protocolVersion); return this.uiServices.get(protocolVersion)?.requestHandler(request); diff --git a/src/charging-station/ui-server/UIHttpServer.ts b/src/charging-station/ui-server/UIHttpServer.ts index a831446b..ccafb084 100644 --- a/src/charging-station/ui-server/UIHttpServer.ts +++ b/src/charging-station/ui-server/UIHttpServer.ts @@ -126,7 +126,7 @@ export class UIHttpServer extends AbstractUIServer { ) ) .then((protocolResponse: ProtocolResponse) => { - if (Utils.isNullOrUndefined(protocolResponse)) { + if (!Utils.isNullOrUndefined(protocolResponse)) { this.sendResponse(protocolResponse); } })