}
private initializeWorkerImplementation(): void {
- !this.workerImplementation &&
+ this.workerImplementation === null &&
(this.workerImplementation = WorkerFactory.getWorkerImplementation<ChargingStationWorkerData>(
this.workerScript,
Configuration.getWorker().processType,
}
}
- private workerEventStarted(data: ChargingStationData) {
+ private workerEventStarted = (data: ChargingStationData) => {
this.uiServer?.chargingStations.set(data.stationInfo.hashId, data);
++this.numberOfStartedChargingStations;
- }
+ };
- private workerEventStopped(data: ChargingStationData) {
+ private workerEventStopped = (data: ChargingStationData) => {
this.uiServer?.chargingStations.set(data.stationInfo.hashId, data);
--this.numberOfStartedChargingStations;
- }
+ };
- private workerEventUpdated(data: ChargingStationData) {
+ private workerEventUpdated = (data: ChargingStationData) => {
this.uiServer?.chargingStations.set(data.stationInfo.hashId, data);
- }
+ };
private workerEventPerformanceStatistics = (data: Statistics) => {
this.storage.storePerformanceStatistics(data) as void;
'Content-Type': 'application/json',
})
.end(JSON.stringify(payload));
- this.responseHandlers.delete(uuid);
} else {
logger.error(
`${this.logPrefix(moduleName, 'sendResponse')} Response for unknown request id: ${uuid}`
`${this.logPrefix(moduleName, 'sendResponse')} Error at sending response id '${uuid}':`,
error
);
+ } finally {
+ this.responseHandlers.delete(uuid);
}
}
const ws = this.responseHandlers.get(responseId) as WebSocket;
if (ws?.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify(response));
+ } else {
+ logger.error(
+ `${this.logPrefix(
+ moduleName,
+ 'sendResponse'
+ )} Error at sending response id '${responseId}', WebSocket is not open: ${
+ ws?.readyState
+ }`
+ );
}
- this.responseHandlers.delete(responseId);
} else {
logger.error(
`${this.logPrefix(
)} Error at sending response id '${responseId}':`,
error
);
+ } finally {
+ this.responseHandlers.delete(responseId);
}
}