Ensure 1:1 mapping between charging station instance and its OCPP services
[e-mobility-charging-stations-simulator.git] / src / charging-station / ocpp / 1.6 / OCPP16IncomingRequestService.ts
index c9f9042fb82fdd5ad5e5a707463eb8a4b5ccab49..d0d7bf09c697b3221133ac4979bab5c8686f50ea 100644 (file)
@@ -28,7 +28,10 @@ import tar from 'tar';
 export default class OCPP16IncomingRequestService extends OCPPIncomingRequestService {
   private incomingRequestHandlers: Map<OCPP16IncomingRequestCommand, IncomingRequestHandler>;
 
-  constructor(chargingStation: ChargingStation) {
+  public constructor(chargingStation: ChargingStation) {
+    if (new.target?.name === 'OCPP16IncomingRequestService') {
+      throw new TypeError('Cannot construct OCPP16IncomingRequestService instances directly');
+    }
     super(chargingStation);
     this.incomingRequestHandlers = new Map<OCPP16IncomingRequestCommand, IncomingRequestHandler>([
       [OCPP16IncomingRequestCommand.RESET, this.handleRequestReset.bind(this)],