From 9934652ccbc6e7e63b2a029ff294093aa22d128c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 17 Apr 2022 18:18:30 +0200 Subject: [PATCH] Simplify incoming OCPP request payload parsing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ChargingStation.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index a187ddd0..b570f74a 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -1486,12 +1486,12 @@ export default class ChargingStation { try { const request = JSON.parse(data.toString()) as IncomingRequest | Response | ErrorResponse; if (Utils.isIterable(request)) { - [messageType] = request; + [messageType, messageId] = request; // Check the type of message switch (messageType) { // Incoming Message case MessageType.CALL_MESSAGE: - [, messageId, commandName, commandPayload] = request as IncomingRequest; + [, , commandName, commandPayload] = request as IncomingRequest; if (this.getEnableStatistics()) { this.performanceStatistics.addRequestStatistic(commandName, messageType); } @@ -1509,7 +1509,7 @@ export default class ChargingStation { break; // Outcome Message case MessageType.CALL_RESULT_MESSAGE: - [, messageId, commandPayload] = request as Response; + [, , commandPayload] = request as Response; // Respond cachedRequest = this.requests.get(messageId); if (Utils.isIterable(cachedRequest)) { @@ -1536,7 +1536,7 @@ export default class ChargingStation { break; // Error Message case MessageType.CALL_ERROR_MESSAGE: - [, messageId, errorType, errorMessage, errorDetails] = request as ErrorResponse; + [, , errorType, errorMessage, errorDetails] = request as ErrorResponse; cachedRequest = this.requests.get(messageId); if (Utils.isIterable(cachedRequest)) { [, rejectCallback, requestCommandName] = cachedRequest; -- 2.34.1