X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fui-server%2Fui-services%2FAbstractUIService.ts;h=e72af5c0549fa1feb2f4c9bfd66225f53fe76e27;hb=6c1761d470507ea23d186be61b94ca7375c5144a;hp=e27577d353e004491a7e926facc24cce4efa41d4;hpb=1f7fa4de53a1b28324f362402f61b81b28d75c2c;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 e27577d3..e72af5c0 100644 --- a/src/charging-station/ui-server/ui-services/AbstractUIService.ts +++ b/src/charging-station/ui-server/ui-services/AbstractUIService.ts @@ -1,13 +1,12 @@ -import { RawData } from 'ws'; +import type { RawData } from 'ws'; import BaseError from '../../../exception/BaseError'; import { Bootstrap } from '../../../internal'; -import { JsonType } from '../../../types/JsonType'; +import type { JsonType } from '../../../types/JsonType'; import { ProcedureName, ProtocolRequest, ProtocolRequestHandler, - ProtocolResponse, ProtocolVersion, RequestPayload, ResponsePayload, @@ -80,31 +79,20 @@ export default abstract class AbstractUIService { procedureName: ProcedureName, requestPayload: RequestPayload ): void { - this.uiServer.sendRequest(this.buildProtocolRequest(messageId, procedureName, requestPayload)); + this.uiServer.sendRequest( + this.uiServer.buildProtocolRequest(messageId, procedureName, requestPayload) + ); } public sendResponse(messageId: string, responsePayload: ResponsePayload): void { - this.uiServer.sendResponse(this.buildProtocolResponse(messageId, responsePayload)); + this.uiServer.sendResponse(this.uiServer.buildProtocolResponse(messageId, responsePayload)); } public logPrefix(modName: string, methodName: string): string { return this.uiServer.logPrefix(modName, methodName); } - private buildProtocolRequest( - messageId: string, - procedureName: ProcedureName, - requestPayload: RequestPayload - ): string { - return JSON.stringify([messageId, procedureName, requestPayload] as ProtocolRequest); - } - - private buildProtocolResponse(messageId: string, responsePayload: ResponsePayload): string { - return JSON.stringify([messageId, responsePayload] as ProtocolResponse); - } - - // Validate the raw data received from the WebSocket - // TODO: should probably be moved to the ws verify clients callback + // Validate the raw data received from the UI server private requestValidation(rawData: RawData | JsonType): ProtocolRequest { // logger.debug( // `${this.logPrefix(