X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2Fui-websocket-services%2FUIServiceUtils.ts;h=9427c08e5aa61b466a77e6caa5f111e3af8147ed;hb=6f35d2daed5ff5d26de15c1547ffa3dbd013c5b3;hp=55e4c0cd22f0c2db4e0ac81e24e0cbcc1c886769;hpb=1f5df42ad17d09d3a1f53f6618eba325a403d7ad;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/ui-websocket-services/UIServiceUtils.ts b/src/charging-station/ui-websocket-services/UIServiceUtils.ts index 55e4c0cd..9427c08e 100644 --- a/src/charging-station/ui-websocket-services/UIServiceUtils.ts +++ b/src/charging-station/ui-websocket-services/UIServiceUtils.ts @@ -1,23 +1,36 @@ -import { Protocol, ProtocolVersion } from '../../types/UiProtocol'; +import { Protocol, ProtocolVersion } from '../../types/UIProtocol'; import { IncomingMessage } from 'http'; import Utils from '../../utils/Utils'; import logger from '../../utils/Logger'; export class UIServiceUtils { - public static handleProtocols = (protocols: Set, request: IncomingMessage): string | false => { + public static handleProtocols = ( + protocols: Set, + request: IncomingMessage + ): string | false => { let protocolIndex: number; let protocol: Protocol; let version: ProtocolVersion; for (const fullProtocol of protocols) { protocolIndex = fullProtocol.indexOf(Protocol.UI); - protocol = fullProtocol.substring(protocolIndex, protocolIndex + Protocol.UI.length) as Protocol; + protocol = fullProtocol.substring( + protocolIndex, + protocolIndex + Protocol.UI.length + ) as Protocol; version = fullProtocol.substring(protocolIndex + Protocol.UI.length) as ProtocolVersion; - if (Object.values(Protocol).includes(protocol) && Object.values(ProtocolVersion).includes(version)) { + if ( + Object.values(Protocol).includes(protocol) && + Object.values(ProtocolVersion).includes(version) + ) { return fullProtocol; } } - logger.error(`${Utils.logPrefix(' UI WebSocket Server:')} Unsupported protocol: ${protocol} or protocol version: ${version}`); + logger.error( + `${Utils.logPrefix( + ' UI WebSocket Server:' + )} Unsupported protocol: ${protocol} or protocol version: ${version}` + ); return false; }; }