X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FUIWebSocketServer.ts;h=5ffc9e0c640320a36f22fb3658afe7478747f32b;hb=de17a5668a671531e9c5ec9563b0b02d6d5a3f27;hp=083f95bcdbac1022a90ccae19d786a7e52594bd3;hpb=d18886407cdb8b8148c87492f2c953075e708401;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/UIWebSocketServer.ts b/src/charging-station/UIWebSocketServer.ts index 083f95bc..5ffc9e0c 100644 --- a/src/charging-station/UIWebSocketServer.ts +++ b/src/charging-station/UIWebSocketServer.ts @@ -5,7 +5,6 @@ import AbstractUIService from './ui-websocket-services/AbstractUIService'; import BaseError from '../exception/BaseError'; import Configuration from '../utils/Configuration'; import { IncomingMessage } from 'http'; -import { JsonType } from '../types/JsonType'; import UIServiceFactory from './ui-websocket-services/UIServiceFactory'; import Utils from '../utils/Utils'; import logger from '../utils/Logger'; @@ -35,9 +34,13 @@ export default class UIWebSocketServer extends Server { public start(): void { this.on('connection', (socket: WebSocket, request: IncomingMessage): void => { const protocolIndex = socket.protocol.indexOf(Protocol.UI); - const version = socket.protocol.substring(protocolIndex + Protocol.UI.length) as ProtocolVersion; + const version = socket.protocol.substring( + protocolIndex + Protocol.UI.length + ) as ProtocolVersion; if (!this.uiServices.has(version)) { - throw new BaseError(`Could not find a UI service implementation for UI protocol version ${version}`); + throw new BaseError( + `Could not find a UI service implementation for UI protocol version ${version}` + ); } // FIXME: check connection validity socket.on('message', (messageData) => { @@ -48,9 +51,16 @@ export default class UIWebSocketServer extends Server { } else { throw new BaseError('UI protocol request is not iterable'); } - this.uiServices.get(version).handleMessage(command, payload).catch(() => { - logger.error(`${this.logPrefix()} Error while handling command %s message: %j`, command, payload); - }); + this.uiServices + .get(version) + .handleMessage(command, payload) + .catch(() => { + logger.error( + `${this.logPrefix()} Error while handling command %s message: %j`, + command, + payload + ); + }); }); socket.on('error', (error) => { logger.error(`${this.logPrefix()} Error on WebSocket: %j`, error);