Fix isEmptyString() semantic
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / AbstractUIServer.ts
index d8ef6340296b5b2ddefa4dbd471529e197a72f40..f69b9b3419924cf47a79dc5aeb0a8e6f4e5cdc00 100644 (file)
@@ -2,19 +2,19 @@ import { type IncomingMessage, Server, type ServerResponse } from 'http';
 
 import type { WebSocket } from 'ws';
 
+import type AbstractUIService from './ui-services/AbstractUIService';
+import UIServiceFactory from './ui-services/UIServiceFactory';
 import type { ChargingStationData } from '../../types/ChargingStationWorker';
 import type { UIServerConfiguration } from '../../types/ConfigurationData';
 import {
   AuthenticationType,
-  ProcedureName,
-  ProtocolRequest,
-  ProtocolResponse,
-  ProtocolVersion,
-  RequestPayload,
-  ResponsePayload,
+  type ProcedureName,
+  type ProtocolRequest,
+  type ProtocolResponse,
+  type ProtocolVersion,
+  type RequestPayload,
+  type ResponsePayload,
 } from '../../types/UIProtocol';
-import type AbstractUIService from './ui-services/AbstractUIService';
-import UIServiceFactory from './ui-services/UIServiceFactory';
 
 export abstract class AbstractUIServer {
   public readonly chargingStations: Map<string, ChargingStationData>;
@@ -45,6 +45,12 @@ export abstract class AbstractUIServer {
     this.chargingStations.clear();
   }
 
+  protected startHttpServer(): void {
+    if (this.httpServer.listening === false) {
+      this.httpServer.listen(this.uiServerConfiguration.options);
+    }
+  }
+
   protected registerProtocolVersionUIService(version: ProtocolVersion): void {
     if (this.uiServices.has(version) === false) {
       this.uiServices.set(version, UIServiceFactory.getUIServiceImplementation(version, this));