export default class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
public async handleRequest(messageId: string, commandName: OCPP16IncomingRequestCommand, commandPayload: Record<string, unknown>): Promise<void> {
let response;
+ const methodName = `handleRequest${commandName}`;
// Call
- if (typeof this['handleRequest' + commandName] === 'function') {
+ if (typeof this[methodName] === 'function') {
try {
// Call the method to build the response
- response = await this['handleRequest' + commandName](commandPayload);
+ response = await this[methodName](commandPayload);
} catch (error) {
// Log
logger.error(this.chargingStation.logPrefix() + ' Handle request error: %j', error);
export default class OCPP16ResponseService extends OCPPResponseService {
public async handleResponse(commandName: OCPP16RequestCommand, payload: Record<string, unknown> | string, requestPayload: Record<string, unknown>): Promise<void> {
- const responseCallbackFn = 'handleResponse' + commandName;
- if (typeof this[responseCallbackFn] === 'function') {
- await this[responseCallbackFn](payload, requestPayload);
+ const responseCallbackMethodName = `handleResponse${commandName}`;
+ if (typeof this[responseCallbackMethodName] === 'function') {
+ await this[responseCallbackMethodName](payload, requestPayload);
} else {
- logger.error(this.chargingStation.logPrefix() + ' Trying to call an undefined response callback function: ' + responseCallbackFn);
+ logger.error(this.chargingStation.logPrefix() + ' Trying to call an undefined response callback method: ' + responseCallbackMethodName);
}
}