Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions build/serviceManager/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ var Service = /** @class */ (function () {
}
};
Service.prototype.initConfiguration = function (data) {
this.log("Service " + data.name + " initialized");
this._CONFIG = data;
this.initialized = true;
if (data.isAuth) {
this.serviceManager.addServiceAuth(this);
if (!this.serviceManager.checkCluster(this)) {
this.initialized = true;
this.log("Service " + data.name + " initialized");
if (data.isAuth) {
this.serviceManager.addServiceAuth(this);
}
}
};
Service.prototype.sendResponse = function (response) {
Expand Down
23 changes: 20 additions & 3 deletions build/serviceManager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ var ServiceManager = /** @class */ (function () {
console.log("Service", service.name, "is the authService");
this.authSerivce = service;
};
ServiceManager.prototype.addService = function (socket) {
this.services.push(new Service_1.default(socket, this));
};
ServiceManager.prototype.checkCluster = function (currentService) {
var isCluster = false;
this.services.forEach(function (service) {
if (service === currentService)
return;
if (service.config && currentService.config) {
if (currentService.config.name === service.name) {
isCluster = true;
}
}
});
if (isCluster) {
var serviceIndex = this.services.findIndex(function (service) { return service === currentService; });
this.services.splice(serviceIndex, 1);
}
return isCluster;
};
ServiceManager.prototype.serviceClosed = function (serviceClosed) {
var serviceIndex = this.services.findIndex(function (service) { return service === serviceClosed; });
if (this.authSerivce === this.services[serviceIndex]) {
Expand Down Expand Up @@ -100,9 +120,6 @@ var ServiceManager = /** @class */ (function () {
res.sendStatus(status);
});
};
ServiceManager.prototype.addService = function (socket) {
this.services.push(new Service_1.default(socket, this));
};
return ServiceManager;
}());
exports.default = ServiceManager;
3 changes: 0 additions & 3 deletions build/test.js

This file was deleted.

10 changes: 6 additions & 4 deletions serviceManager/Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ export default class Service {
}

private initConfiguration(data: Config) {
this.log("Service " + data.name + " initialized");
this._CONFIG = data;
this.initialized = true;
if (data.isAuth) {
this.serviceManager.addServiceAuth(this);
if(!this.serviceManager.checkCluster(this)) {
this.initialized = true;
this.log("Service " + data.name + " initialized");
if (data.isAuth) {
this.serviceManager.addServiceAuth(this);
}
}
}
private sendResponse(response: any) {
Expand Down
26 changes: 22 additions & 4 deletions serviceManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,28 @@ export default class ServiceManager {
this.authSerivce = service;
}

private addService(socket: net.Socket) {
this.services.push(new Service(socket, this));
}

public checkCluster(currentService: Service) {
let isCluster = false;
this.services.forEach((service:Service) => {
if (service === currentService) return;
if (service.config && currentService.config) {
if (currentService.config.name === service.name) {
isCluster = true;
}
}
});

if (isCluster) {
const serviceIndex = this.services.findIndex((service: Service) => service === currentService);
this.services.splice(serviceIndex, 1);
}
return isCluster;
}

public serviceClosed(serviceClosed: Service) {
const serviceIndex = this.services.findIndex((service: Service) => service === serviceClosed);
if (this.authSerivce === this.services[serviceIndex]) { this.authSerivce = null; }
Expand Down Expand Up @@ -80,8 +102,4 @@ export default class ServiceManager {
res.sendStatus(status);
});
}

private addService(socket: net.Socket) {
this.services.push(new Service(socket, this));
}
}