private async onMessage(messageEvent: MessageEvent): Promise<void> {
let [messageType, messageId, commandName, commandPayload, errorDetails]: IncomingRequest = [0, '', '' as IncomingRequestCommand, {}, {}];
- let responseCallback: (payload?: Record<string, unknown> | string, requestPayload?: Record<string, unknown>) => void;
+ let responseCallback: (payload: Record<string, unknown> | string, requestPayload: Record<string, unknown>) => void;
let rejectCallback: (error: OCPPError) => void;
let requestPayload: Record<string, unknown>;
let errMsg: string;
this.ocppResponseService = ocppResponseService;
}
- public async sendMessage(messageId: string, commandParams: any, messageType: MessageType = MessageType.CALL_RESULT_MESSAGE,
- commandName: RequestCommand | IncomingRequestCommand): Promise<any> {
+ public async sendMessage(messageId: string, commandParams: any, messageType: MessageType, commandName: RequestCommand | IncomingRequestCommand): Promise<any> {
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
// Send a message through wsConnection
*/
async function responseCallback(payload: Record<string, unknown> | string, requestPayload: Record<string, unknown>): Promise<void> {
if (self.chargingStation.getEnableStatistics()) {
- self.chargingStation.statistics.addMessage(commandName, messageType);
+ self.chargingStation.statistics.addMessage(commandName, MessageType.CALL_RESULT_MESSAGE);
}
// Send the response
await self.ocppResponseService.handleResponse(commandName as RequestCommand, payload, requestPayload);
*/
function rejectCallback(error: OCPPError): void {
if (self.chargingStation.getEnableStatistics()) {
- self.chargingStation.statistics.addMessage(commandName, messageType);
+ self.chargingStation.statistics.addMessage(commandName, MessageType.CALL_ERROR_MESSAGE);
}
logger.debug(`${self.chargingStation.logPrefix()} Error: %j occurred when calling command %s with parameters: %j`, error, commandName, commandParams);
// Build Exception
...OCPP16IncomingRequestCommand
};
-export type Request = [(payload?: Record<string, unknown>, requestPayload?: Record<string, unknown>) => void, (error?: OCPPError) => void, Record<string, unknown>];
+export type Request = [(payload: Record<string, unknown>, requestPayload: Record<string, unknown>) => void, (error: OCPPError) => void, Record<string, unknown>];
export type IncomingRequest = [MessageType, string, IncomingRequestCommand, Record<string, unknown>, Record<string, unknown>];