fix: address two FIXMEs at websocket events handling
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 20 Jan 2024 20:27:21 +0000 (21:27 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 20 Jan 2024 20:27:21 +0000 (21:27 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts

index 4656444f643c82130968fc96769f82f3503166e6..3f0069aff5c093dcf6b248cdfd8b0cafdc250b3d 100644 (file)
@@ -768,17 +768,17 @@ export class ChargingStation extends EventEmitter {
     )
 
     // Handle WebSocket message
-    // FIXME
-    // eslint-disable-next-line @typescript-eslint/no-misused-promises
-    this.wsConnection.on('message', this.onMessage.bind(this))
+    this.wsConnection.on('message', data => {
+      this.onMessage(data).catch(Constants.EMPTY_FUNCTION)
+    })
     // Handle WebSocket error
     this.wsConnection.on('error', this.onError.bind(this))
     // Handle WebSocket close
     this.wsConnection.on('close', this.onClose.bind(this))
     // Handle WebSocket open
-    // FIXME
-    // eslint-disable-next-line @typescript-eslint/no-misused-promises
-    this.wsConnection.on('open', this.onOpen.bind(this))
+    this.wsConnection.on('open', () => {
+      this.onOpen().catch(Constants.EMPTY_FUNCTION)
+    })
     // Handle WebSocket ping
     this.wsConnection.on('ping', this.onPing.bind(this))
     // Handle WebSocket pong