X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fui-server%2FUIHttpServer.ts;h=159559df1f4cacb6eebaa1f67b8e6cca66ac030a;hb=be245fdab36274873e0a9651589cebd097548076;hp=9e33302682533c68d39e9536cc878bd15a3b68c6;hpb=59b6ed8d1db313ef3371efd8ab5e039cf3dedab0;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ui-server/UIHttpServer.ts b/src/charging-station/ui-server/UIHttpServer.ts index 9e333026..159559df 100644 --- a/src/charging-station/ui-server/UIHttpServer.ts +++ b/src/charging-station/ui-server/UIHttpServer.ts @@ -2,6 +2,8 @@ import type { IncomingMessage, RequestListener, ServerResponse } from 'node:http import { StatusCodes } from 'http-status-codes'; +import { AbstractUIServer } from './AbstractUIServer'; +import { UIServerUtils } from './UIServerUtils'; import { BaseError } from '../../exception'; import { type ProcedureName, @@ -14,7 +16,6 @@ import { type UIServerConfiguration, } from '../../types'; import { Constants, Utils, logger } from '../../utils'; -import { AbstractUIServer, UIServerUtils } from '../internal'; const moduleName = 'UIHttpServer'; @@ -43,7 +44,7 @@ export class UIHttpServer extends AbstractUIServer { public sendResponse(response: ProtocolResponse): void { const [uuid, payload] = response; try { - if (this.responseHandlers.has(uuid) === true) { + if (this.hasResponseHandler(uuid) === true) { const res = this.responseHandlers.get(uuid) as ServerResponse; res .writeHead(this.responseStatusToStatusCode(payload.status), { @@ -124,6 +125,11 @@ export class UIHttpServer extends AbstractUIServer { body ?? Constants.EMPTY_FREEZED_OBJECT ) ) + .then((protocolResponse: ProtocolResponse) => { + if (!Utils.isNullOrUndefined(protocolResponse)) { + this.sendResponse(protocolResponse); + } + }) .catch(Constants.EMPTY_FUNCTION); }); } else {