const version = socket.protocol.substring(protocolIndex + Protocol.UI.length) as ProtocolVersion;
this.uiService = UIServiceFactory.getUIServiceImplementation(version, this);
if (!this.uiService) {
- throw new BaseError(`Could not find a UI service implementation for protocol version ${version}`);
+ throw new BaseError(`Could not find a UI service implementation for UI protocol version ${version}`);
}
// FIXME: check connection validity
socket.on('message', (messageData) => {
if (Utils.isIterable(protocolRequest)) {
[command, payload] = protocolRequest;
} else {
- throw new BaseError('Protocol request is not iterable');
+ throw new BaseError('UI protocol request is not iterable');
}
this.uiService.handleMessage(command, payload).catch(() => {
logger.error(`${this.logPrefix()} Error while handling command %s message: %j`, command, payload);
}
public logPrefix(): string {
- return Utils.logPrefix('WebSocket Server:');
+ return Utils.logPrefix(' UI WebSocket Server:');
}
}
constructor(uiWebSocketServer: UIWebSocketServer) {
this.chargingStations = new Set<string>();
this.uiWebSocketServer = uiWebSocketServer;
- // TODO: Move the shared service code to AbstractUIService
this.messageHandlers = new Map<ProtocolCommand, ProtocolRequestHandler>([
[ProtocolCommand.LIST_CHARGING_STATIONS, this.handleListChargingStations.bind(this)],
]);