From: Jérôme Benoit Date: Sat, 20 Jan 2024 20:27:21 +0000 (+0100) Subject: fix: address two FIXMEs at websocket events handling X-Git-Tag: v1.2.33~43 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=968f0e4757c72476819fb10791460170bb226358;p=e-mobility-charging-stations-simulator.git fix: address two FIXMEs at websocket events handling Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 4656444f..3f0069af 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -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