X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fui-server%2Fui-services%2FAbstractUIService.ts;h=1ec6cf93b20e77363f08ecbb79cb9c10ed9cf656;hb=507a34c154d4877cc261df07b942bcef01b87b4b;hp=541966afbc98f2ad9317d126185ac15e5e4eace8;hpb=6bd808fd1dc554c8d55521b20a064447835ef04c;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ui-server/ui-services/AbstractUIService.ts b/src/charging-station/ui-server/ui-services/AbstractUIService.ts index 541966af..1ec6cf93 100644 --- a/src/charging-station/ui-server/ui-services/AbstractUIService.ts +++ b/src/charging-station/ui-server/ui-services/AbstractUIService.ts @@ -5,6 +5,7 @@ import { ProcedureName, type ProtocolRequest, type ProtocolRequestHandler, + type ProtocolResponse, type ProtocolVersion, type RequestPayload, type ResponsePayload, @@ -65,11 +66,11 @@ export abstract class AbstractUIService { this.broadcastChannelRequests = new Map(); } - public async requestHandler(request: ProtocolRequest): Promise { + public async requestHandler(request: ProtocolRequest): Promise { let messageId: string; let command: ProcedureName; let requestPayload: RequestPayload | undefined; - let responsePayload: ResponsePayload; + let responsePayload: ResponsePayload | undefined; try { [messageId, command, requestPayload] = request; @@ -98,26 +99,26 @@ export abstract class AbstractUIService { errorStack: (error as Error).stack, errorDetails: (error as OCPPError).details, }; - } finally { - // Send response for payload not forwarded to broadcast channel - if (!Utils.isNullOrUndefined(responsePayload)) { - this.sendResponse(messageId, responsePayload); - } + } + if (!Utils.isNullOrUndefined(responsePayload)) { + return this.uiServer.buildProtocolResponse(messageId, responsePayload); } } - public sendRequest( - messageId: string, - procedureName: ProcedureName, - requestPayload: RequestPayload - ): void { - this.uiServer.sendRequest( - this.uiServer.buildProtocolRequest(messageId, procedureName, requestPayload) - ); - } + // public sendRequest( + // messageId: string, + // procedureName: ProcedureName, + // requestPayload: RequestPayload + // ): void { + // this.uiServer.sendRequest( + // this.uiServer.buildProtocolRequest(messageId, procedureName, requestPayload) + // ); + // } public sendResponse(messageId: string, responsePayload: ResponsePayload): void { - this.uiServer.sendResponse(this.uiServer.buildProtocolResponse(messageId, responsePayload)); + if (this.uiServer.hasResponseHandler(messageId)) { + this.uiServer.sendResponse(this.uiServer.buildProtocolResponse(messageId, responsePayload)); + } } public logPrefix = (modName: string, methodName: string): string => {