fix: fix undefined payload check in UI server code
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 26 May 2023 13:07:53 +0000 (15:07 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 26 May 2023 13:07:53 +0000 (15:07 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/Bootstrap.ts
src/charging-station/ui-server/AbstractUIServer.ts
src/charging-station/ui-server/UIHttpServer.ts

index a1ee4ff2342b01854ffd913ff83ec1dec1abbd0b..5e1ac3eb4b1b447720b5489e629ef143e510a5c7 100644 (file)
@@ -129,7 +129,7 @@ export class Bootstrap extends EventEmitter {
 
   public async stop(): Promise<void> {
     if (isMainThread && this.started === true) {
-      await this.uiServer?.sendBroadcastChannelRequest(
+      await this.uiServer?.sendRequestOnBroadcastChannel(
         this.uiServer.buildProtocolRequest(
           Utils.generateUUID(),
           ProcedureName.STOP_CHARGING_STATION,
index af5c01295d16ce39d78906f429f15c22424917d5..8552a572f4bf08ab3134da682f3c444f2aa54773 100644 (file)
@@ -46,7 +46,7 @@ export abstract class AbstractUIServer {
     this.chargingStations.clear();
   }
 
-  public async sendBroadcastChannelRequest(request: ProtocolRequest): Promise<ProtocolResponse> {
+  public async sendRequestOnBroadcastChannel(request: ProtocolRequest): Promise<ProtocolResponse> {
     const protocolVersion = ProtocolVersion['0.0.1'];
     this.registerProtocolVersionUIService(protocolVersion);
     return this.uiServices.get(protocolVersion)?.requestHandler(request);
index a831446b9c5f93d0e8bd3cd55543dc79957b88bc..ccafb0845df0307a2577e34b68f5d4e8742ff18f 100644 (file)
@@ -126,7 +126,7 @@ export class UIHttpServer extends AbstractUIServer {
                 )
               )
               .then((protocolResponse: ProtocolResponse) => {
-                if (Utils.isNullOrUndefined(protocolResponse)) {
+                if (!Utils.isNullOrUndefined(protocolResponse)) {
                   this.sendResponse(protocolResponse);
                 }
               })