import { Protocol, ProtocolVersion } from '../../types/UIProtocol';
-import WebSocket, { OPEN, Server, ServerOptions } from 'ws';
+import WebSocket, { OPEN, Server } from 'ws';
import AbstractUIService from './ui-services/AbstractUIService';
import Configuration from '../../utils/Configuration';
import { IncomingMessage } from 'http';
+import { ServerOptions } from '../../types/ConfigurationData';
import UIServiceFactory from './ui-services/UIServiceFactory';
import Utils from '../../utils/Utils';
import logger from '../../utils/Logger';
private readonly uiServices: Map<ProtocolVersion, AbstractUIService>;
public constructor(options?: ServerOptions, callback?: () => void) {
- // Create the WebSocket Server
+ // Create the WebSocket server
super(options ?? Configuration.getUIServer().options, callback);
this.chargingStations = new Set<string>();
this.uiServices = new Map<ProtocolVersion, AbstractUIService>();
+import { ServerOptions as HttpServerOptions } from 'http';
import { StorageType } from './Storage';
import { ServerOptions as WSServerOptions } from 'ws';
import type { WorkerChoiceStrategy } from 'poolifier';
import { WorkerProcessType } from './Worker';
+export type ServerOptions = WSServerOptions & HttpServerOptions;
+
export enum SupervisionUrlDistribution {
ROUND_ROBIN = 'round-robin',
RANDOM = 'random',
export interface UIServerConfiguration {
enabled?: boolean;
- options?: WSServerOptions;
+ options?: ServerOptions;
}
export interface StorageConfiguration {
import ConfigurationData, {
+ ServerOptions,
StationTemplateUrl,
StorageConfiguration,
SupervisionUrlDistribution,
import { EmptyObject } from '../types/EmptyObject';
import { FileType } from '../types/FileType';
import { HandleErrorParams } from '../types/Error';
-import { ServerOptions } from 'ws';
import { StorageType } from '../types/Storage';
import type { WorkerChoiceStrategy } from 'poolifier';
import WorkerConstants from '../worker/WorkerConstants';
}
static getUIServer(): UIServerConfiguration {
+ if (Configuration.objectHasOwnProperty(Configuration.getConfig(), 'uiWebSocketServer')) {
+ console.error(
+ chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration section 'uiWebSocketServer' usage. Use 'uiServer' instead}`
+ );
+ }
let options: ServerOptions = {
host: Constants.DEFAULT_UI_WEBSOCKET_SERVER_HOST,
port: Constants.DEFAULT_UI_WEBSOCKET_SERVER_PORT,