control-freak-ide/server/nodejs/dist/arm/_build/wamp/server.js
plastic-hub-dev-node-saturn 538369cff7 latest
2021-05-12 18:35:18 +02:00

41 lines
942 B
JavaScript

"use strict";
const session_manager_1 = require("./session-manager");
// import * as Debug from 'debug';
const ws_1 = require("ws");
// const DEBUG = Debug('wamp:server');
/**
*
*
* @class Server
*/
class Server {
/**
* Creates an instance of Server.
*
* @param {OptionsInterface} options
*/
constructor(options) {
const REALMS = options.realms;
this.port = options.port;
this.wss = options.ws || new ws_1.Server({ port: this.port });
session_manager_1.default.registerRealms(Array.isArray(REALMS) ? REALMS : [REALMS]);
this.listen();
}
/**
*
*/
close() {
this.wss.close();
}
/**
*
*
* @private
*/
listen() {
console.log('listening on port %s', this.port);
this.wss.on('connection', session_manager_1.default.createSession);
}
}
exports.Server = Server;
//# sourceMappingURL=server.js.map