Use return consistently in sendMessage()
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 2 Oct 2021 10:01:57 +0000 (12:01 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 2 Oct 2021 10:01:57 +0000 (12:01 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/charging-station/ocpp/OCPPRequestService.ts

index 842b644613bfa544236b9c44a49786d9603e0891..b72b596c7d11c8db8228115e5940e0ce73c381e4 100644 (file)
@@ -56,11 +56,10 @@ export default abstract class OCPPRequestService {
       // Response?
       if (messageType !== MessageType.CALL_MESSAGE) {
         // Yes: send Ok
-        resolve(commandParams);
-      } else {
-        // Send timeout
-        setTimeout(() => rejectCallback(new OCPPError(ErrorType.GENERIC_ERROR, `Timeout for message id '${messageId}' with content '${messageToSend}'`, commandParams?.details ?? {}), false), Constants.OCPP_SOCKET_TIMEOUT);
+        return resolve(commandParams);
       }
+      // Send timeout
+      setTimeout(() => rejectCallback(new OCPPError(ErrorType.GENERIC_ERROR, `Timeout for message id '${messageId}' with content '${messageToSend}'`, commandParams?.details ?? {}), false), Constants.OCPP_SOCKET_TIMEOUT);
 
       /**
        * Function that will receive the request's response