refactor: remove uneeded unknown intermediate type cast
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / AbstractUIServer.ts
index 8552a572f4bf08ab3134da682f3c444f2aa54773..5dbe5b20dab588c875f36459c4adba0dedb46d21 100644 (file)
@@ -33,7 +33,7 @@ export abstract class AbstractUIServer {
   public buildProtocolRequest(
     id: string,
     procedureName: ProcedureName,
-    requestPayload: RequestPayload
+    requestPayload: RequestPayload,
   ): ProtocolRequest {
     return [id, procedureName, requestPayload];
   }
@@ -46,10 +46,16 @@ export abstract class AbstractUIServer {
     this.chargingStations.clear();
   }
 
-  public async sendRequestOnBroadcastChannel(request: ProtocolRequest): Promise<ProtocolResponse> {
+  public async sendInternalRequest(request: ProtocolRequest): Promise<ProtocolResponse> {
     const protocolVersion = ProtocolVersion['0.0.1'];
     this.registerProtocolVersionUIService(protocolVersion);
-    return this.uiServices.get(protocolVersion)?.requestHandler(request);
+    return this.uiServices
+      .get(protocolVersion)
+      ?.requestHandler(request) as Promise<ProtocolResponse>;
+  }
+
+  public hasResponseHandler(id: string): boolean {
+    return this.responseHandlers.has(id);
   }
 
   protected startHttpServer(): void {
@@ -100,6 +106,6 @@ export abstract class AbstractUIServer {
   public abstract logPrefix(
     moduleName?: string,
     methodName?: string,
-    prefixSuffix?: string
+    prefixSuffix?: string,
   ): string;
 }