-
Notifications
You must be signed in to change notification settings - Fork 46
/
server.js
executable file
·34 lines (29 loc) · 1.08 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
const config = require('config');
const WebsocketConnectionManager = require('./lib/main/ws-connection-manager.js');
const ConnectionManager = require('./lib/main/connection-manager.js');
const SFUModuleManager = require('./lib/main/sfu-module-manager.js');
const Janitor = require('./lib/main/janitor.js');
const Logger = require('./lib/common/logger.js');
const HTTP_SERVER_HOST = config.has('clientHost') ? config.get('clientHost') : '127.0.0.1';
const HTTP_SERVER_PORT = config.get('clientPort');
const WS_SERVER_OPTIONS = config.has('wsServerOptions')
? config.get('wsServerOptions')
: { maxPayload: 51200 };
const WSManager = new WebsocketConnectionManager(
HTTP_SERVER_HOST,
HTTP_SERVER_PORT,
'/bbb-webrtc-sfu',
WS_SERVER_OPTIONS
);
const CM = new ConnectionManager();
SFUModuleManager.start().then(() => {
CM.setupModuleRouting(SFUModuleManager.modules);
CM.addAdapter(WSManager);
Janitor.clockIn();
}).catch((error) => {
Logger.error('Failed to start SFU Module Manager', error);
SFUModuleManager.stopModules().then(() => {
process.exit(1);
});
});