UNPKG

raas-server

Version:
38 lines 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const events_1 = require("events"); const clientService_1 = require("./services/clientService"); const net = require("net"); const runtimeService_1 = require("./services/runtimeService"); const notificationService_1 = require("./services/notificationService"); const installationService_1 = require("./services/installationService"); const installableServerService_1 = require("./services/installableServerService"); class Server { constructor() { this.emitter = new events_1.EventEmitter(); this.clientService = new clientService_1.ClientService(); this.notificationService = new notificationService_1.NotificationService(this.clientService); this.runtimeService = new runtimeService_1.RuntimeService(this.notificationService); this.installableServerService = new installableServerService_1.InstallableServerService(this.clientService); this.installationService = new installationService_1.InstallationService(this.clientService); this.emitter.on('shutdown', this.shutdown); } start(port) { this.server = net.createServer(this.connectClient.bind(this)); this.server.listen(port); } connectClient(s) { const client = this.clientService.connectClient(s); client.register(this.runtimeService, this.notificationService, this.installableServerService, this.installationService); client.onDisconnected.on(() => this.disconnectClient(client)); client.listen(); } disconnectClient(client) { this.clientService.disconnectClient(client); } shutdown() { this.server.close(); } } exports.Server = Server; //# sourceMappingURL=server.js.map