X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=src%2Fcharging-station%2Fui-server%2FUIServerFactory.ts;h=b0020b2e872e11dc6a59b0a5491f265203453a45;hb=53e5fd67dea2dd83ec9c34d963dd6e502ec46f5c;hp=cdcd251a5d45e8c5c8bd7175ab7519f4b83c5a6e;hpb=fe94fce08a020e0c35e354c2282ec0587a605f4e;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ui-server/UIServerFactory.ts b/src/charging-station/ui-server/UIServerFactory.ts index cdcd251a..b0020b2e 100644 --- a/src/charging-station/ui-server/UIServerFactory.ts +++ b/src/charging-station/ui-server/UIServerFactory.ts @@ -1,7 +1,10 @@ -import { AbstractUIServer } from './AbstractUIServer'; +import chalk from 'chalk'; + +import { ServerOptions } from '../../types/ConfigurationData'; import { ApplicationProtocol } from '../../types/UIProtocol'; import Configuration from '../../utils/Configuration'; -import { ServerOptions } from '../../types/ConfigurationData'; +import { AbstractUIServer } from './AbstractUIServer'; +import { UIServiceUtils } from './ui-services/UIServiceUtils'; import UIWebSocketServer from './UIWebSocketServer'; export default class UIServerFactory { @@ -11,12 +14,18 @@ export default class UIServerFactory { public static getUIServerImplementation( applicationProtocol: ApplicationProtocol, - options?: ServerOptions, - callback?: () => void + options?: ServerOptions ): AbstractUIServer | null { + if (!UIServiceUtils.isLoopback(options?.host)) { + console.warn( + chalk.magenta( + 'Loopback address not detected in UI server configuration. This is not recommended.' + ) + ); + } switch (applicationProtocol) { case ApplicationProtocol.WS: - return new UIWebSocketServer(options ?? Configuration.getUIServer().options, callback); + return new UIWebSocketServer(options ?? Configuration.getUIServer().options); default: return null; }