refactor: trivial cleanups
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / AbstractUIServer.ts
index 2f6f950b938fd94e74557e4b4f3206d5ae0e2939..e689441633b47e0c7a6b52cd4c90fb1de58221be 100644 (file)
@@ -11,7 +11,7 @@ import {
   type ProcedureName,
   type ProtocolRequest,
   type ProtocolResponse,
-  type ProtocolVersion,
+  ProtocolVersion,
   type RequestPayload,
   type ResponsePayload,
   type UIServerConfiguration,
@@ -46,14 +46,14 @@ export abstract class AbstractUIServer {
     this.chargingStations.clear();
   }
 
-  public async sendBroadcastChannelRequest(
-    id: string,
-    procedureName: ProcedureName,
-    requestPayload: RequestPayload
-  ): Promise<void> {
-    for (const uiService of this.uiServices.values()) {
-      await uiService.requestHandler(this.buildProtocolRequest(id, procedureName, requestPayload));
-    }
+  public async sendInternalRequest(request: ProtocolRequest): Promise<ProtocolResponse> {
+    const protocolVersion = ProtocolVersion['0.0.1'];
+    this.registerProtocolVersionUIService(protocolVersion);
+    return this.uiServices.get(protocolVersion)?.requestHandler(request);
+  }
+
+  public hasResponseHandler(id: string): boolean {
+    return this.responseHandlers.has(id);
   }
 
   protected startHttpServer(): void {