@loopback/socketio
Version:
LoopBack's WebSocket server based on socket.io
32 lines • 1.39 kB
JavaScript
// Copyright IBM Corp. and LoopBack contributors 2020. All Rights Reserved.
// Node module: @loopback/socketio
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
Object.defineProperty(exports, "__esModule", { value: true });
exports.SocketIoApplication = exports.ERR_NO_MULTI_SERVER = void 0;
const core_1 = require("@loopback/core");
const util_1 = require("util");
const keys_1 = require("./keys");
const socketio_component_1 = require("./socketio.component");
exports.ERR_NO_MULTI_SERVER = (0, util_1.format)('SocketApplication does not support multiple servers!', 'To create your own server bindings, please extend the Application class.');
class SocketIoApplication extends core_1.Application {
constructor(config) {
super(config);
this.component(socketio_component_1.SocketIoComponent);
}
/**
* The main Socket server instance providing Socket connections for this application.
*/
get socketServer() {
return this.getSync(keys_1.SocketIoBindings.SERVER);
}
server(server, name) {
if (this.findByTag('server').length > 0) {
throw new Error(exports.ERR_NO_MULTI_SERVER);
}
return super.server(server, name);
}
}
exports.SocketIoApplication = SocketIoApplication;
//# sourceMappingURL=socketio.application.js.map
;