Add return type to getLogger
[e-mobility-charging-stations-simulator.git] / src / charging-station / UIWebSocketServer.ts
index 59186a5e30da2f4d6cf4a55d770fcf008cb7533c..a899076338709c1a19baa10d6d91e88fa7101473 100644 (file)
@@ -1,13 +1,13 @@
 import { Protocol, ProtocolCommand, ProtocolRequest, ProtocolVersion } from '../types/UIProtocol';
 import WebSocket, { OPEN, Server, ServerOptions } from 'ws';
 
-import AbstractUIService from './UIWebSocketServices/AbstractUIService';
+import AbstractUIService from './ui-websocket-services/AbstractUIService';
 import BaseError from '../exception/BaseError';
 import Configuration from '../utils/Configuration';
 import { IncomingMessage } from 'http';
-import UIServiceFactory from './UIWebSocketServices/UIServiceFactory';
+import UIServiceFactory from './ui-websocket-services/UIServiceFactory';
 import Utils from '../utils/Utils';
-import logger from '../utils/Logger';
+import getLogger from '../utils/Logger';
 
 export default class UIWebSocketServer extends Server {
   public readonly chargingStations: Set<string>;
@@ -23,7 +23,7 @@ export default class UIWebSocketServer extends Server {
     }
   }
 
-  public broadcastToClients(message: string | Record<string, unknown>): void {
+  public broadcastToClients(message: string): void {
     for (const client of this.clients) {
       if (client?.readyState === OPEN) {
         client.send(message);
@@ -48,11 +48,11 @@ export default class UIWebSocketServer extends Server {
           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);
+          getLogger().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);
+        getLogger().error(`${this.logPrefix()} Error on WebSocket: %j`, error);
       });
     });
   }