X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fui-server%2FUIWebSocketServer.ts;h=5ddf0e5901109321606ac5607b6aa821a7956648;hb=b9da1bc288a2a6ffccfbca6cd19aa195bc6ccfbf;hp=bf9eb8b3a66b753907d98a2df18120dcd25291ce;hpb=59b6ed8d1db313ef3371efd8ab5e039cf3dedab0;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ui-server/UIWebSocketServer.ts b/src/charging-station/ui-server/UIWebSocketServer.ts index bf9eb8b3..5ddf0e59 100644 --- a/src/charging-station/ui-server/UIWebSocketServer.ts +++ b/src/charging-station/ui-server/UIWebSocketServer.ts @@ -4,6 +4,8 @@ import type { Duplex } from 'node:stream'; import { StatusCodes } from 'http-status-codes'; import WebSocket, { type RawData, WebSocketServer } from 'ws'; +import { AbstractUIServer } from './AbstractUIServer'; +import { UIServerUtils } from './UIServerUtils'; import { type ProtocolRequest, type ProtocolResponse, @@ -11,7 +13,6 @@ import { WebSocketCloseEventStatusCode, } from '../../types'; import { Constants, Utils, logger } from '../../utils'; -import { AbstractUIServer, UIServerUtils } from '../internal'; const moduleName = 'UIWebSocketServer'; @@ -48,7 +49,15 @@ export class UIWebSocketServer extends AbstractUIServer { } const [requestId] = request as ProtocolRequest; this.responseHandlers.set(requestId, ws); - this.uiServices.get(version)?.requestHandler(request).catch(Constants.EMPTY_FUNCTION); + this.uiServices + .get(version) + ?.requestHandler(request) + .then((protocolResponse: ProtocolResponse) => { + if (!Utils.isNullOrUndefined(protocolResponse)) { + this.sendResponse(protocolResponse); + } + }) + .catch(Constants.EMPTY_FUNCTION); }); ws.on('error', (error) => { logger.error(`${this.logPrefix(moduleName, 'start.ws.onerror')} WebSocket error:`, error);