} from '../types/WorkerBroadcastChannel';
import { ResponseStatus } from '../ui/web/src/type/UIProtocol';
import logger from '../utils/Logger';
-import ChargingStation from './ChargingStation';
+import type ChargingStation from './ChargingStation';
import WorkerBroadcastChannel from './WorkerBroadcastChannel';
const moduleName = 'ChargingStationWorkerBroadcastChannel';
if (this.isResponse(messageEvent.data)) {
return;
}
+ if (Array.isArray(messageEvent.data) === false) {
+ throw new BaseError('Worker broadcast channel protocol request is not an array');
+ }
const [uuid, command, requestPayload] = messageEvent.data as BroadcastChannelRequest;
case BroadcastChannelProcedureName.STOP_CHARGING_STATION:
await this.chargingStation.stop();
break;
+ case BroadcastChannelProcedureName.OPEN_CONNECTION:
+ this.chargingStation.openWSConnection();
+ break;
+ case BroadcastChannelProcedureName.CLOSE_CONNECTION:
+ this.chargingStation.closeWSConnection();
+ break;
default:
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
- throw new BaseError(`Unknown broadcast channel command: ${command}`);
+ throw new BaseError(`Unknown worker broadcast channel command: ${command}`);
}
}