-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,
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 UI server
private requestValidation(rawData: RawData | JsonType): ProtocolRequest {
// logger.debug(
// TODO: remove cast to unknown
return {
status: ResponseStatus.SUCCESS,
- ...Array.from(this.uiServer.chargingStations.values()),
+ ...[...this.uiServer.chargingStations.values()],
} as unknown as ResponsePayload;
}