提交 56998c84 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

minor changes

上级 f26800ee
......@@ -7,4 +7,3 @@
# Others
/npm-debug.log
/NO_GIT/
/art/
......@@ -19,16 +19,6 @@ const VALID_WORKER_PARAMETERS =
class Server extends EventEmitter
{
/**
* @param {[Object]} options
* @param {[String]} options.logLevel 'debug'/'warn'/'error'
* @param {[String|boolean]} options.rtcListenIPv4
* @param {[String|boolean]} options.rtcListenIPv6
* @param {[Number]} options.rtcMinPort
* @param {[Number]} options.rtcMaxPort
* @param {[String]} options.dtlsCertificateFile DTLS pubic certificate file
* @param {[String]} options.dtlsPrivateKeyFile DTLS private key file
*/
constructor(options)
{
logger.debug('constructor() [options:%o]', options);
......@@ -40,13 +30,13 @@ class Server extends EventEmitter
let numWorkers = DEFAULT_NUM_WORKERS;
let parameters = [];
// Set of Worker instances
// Set of Worker instances.
this._workers = new Set();
// Closed flag
// Closed flag.
this._closed = false;
// Normalize some options
// Normalize some options.
if (check.integer(options.numWorkers) && check.positive(options.numWorkers))
numWorkers = options.numWorkers;
......@@ -75,13 +65,13 @@ class Server extends EventEmitter
parameters.push(`--${key}=${String(options[key])}`);
}
// Create Worker instances
// Create Worker instances.
for (let i = 1; i <= numWorkers; i++)
{
let workerId = serverId + '#' + i;
let workerParameters = parameters.slice(0);
// Distribute RTC ports for each worker
// Distribute RTC ports for each worker.
let rtcMinPort = options.rtcMinPort;
let rtcMaxPort = options.rtcMaxPort;
......@@ -99,9 +89,8 @@ class Server extends EventEmitter
workerParameters.push(`--rtcMinPort=${rtcMinPort}`);
workerParameters.push(`--rtcMaxPort=${rtcMaxPort}`);
// Create a Worker instance
// (do it in a separate method to avoid creating a callback
// function within a loop)
// Create a Worker instance (do it in a separate method to avoid creating
// a callback function within a loop).
this._addWorker(new Worker(workerId, workerParameters));
}
}
......@@ -112,7 +101,7 @@ class Server extends EventEmitter
}
/**
* Close the Server
* Close the Server.
*/
close(error)
{
......@@ -126,15 +115,16 @@ class Server extends EventEmitter
this._closed = true;
// Close every Worker
// Close every Worker.
this._workers.forEach((worker) => worker.close());
this.emit('close', error);
}
/**
* Dump the Server
* @return {Promise} Resolves to object data
* Dump the Server.
*
* @return {Promise} Resolves to object data.
*/
dump()
{
......@@ -171,8 +161,10 @@ class Server extends EventEmitter
}
/**
* Update Server settings
* @param {Object} options Object with modified settings
* Update Server settings.
*
* @param {Object} options - Object with modified settings.
*
* @return {Promise}
*/
updateSettings(options)
......@@ -195,9 +187,11 @@ class Server extends EventEmitter
}
/**
* Create a Room instance
* @param {[Object]} options
* @param {[Boolean]} options.forceUniquePayloadTypes
* Create a Room instance.
*
* @param {Object} [options]
* @param {boolean} [options.forceUniquePayloadTypes=false]
* @return {Room}
*/
Room(options)
......@@ -214,8 +208,8 @@ class Server extends EventEmitter
_addWorker(worker)
{
// Store the Worker instance and remove it when closed
// Also, if it is the latest Worker then close the Server
// Store the Worker instance and remove it when closed.
// Also, if it is the latest Worker then close the Server.
this._workers.add(worker);
worker.on('close', (error) =>
{
......
......@@ -10,31 +10,27 @@ const extra = require('./extra');
const PKG = require('../package.json');
// Set of Server instances
// Set of Server instances.
let servers = new Set();
module.exports =
{
/**
* Create a Server instance
* @param {Object} options Server options
* @param {Number} options.numWorkers Number of child workers
* - Default: number of CPU cores
* @param {String} options.logLevel Log level
* - Values: 'debug' / 'warn' / 'error'
* - Default 'debug'
* @param {String|Boolean} options.rtcListenIPv4 IPv4 for RTC
* - Values: IPv4 / true (auto-detect), false (disable)
* - Default: true
* @param {String|Boolean} options.rtcListenIPv6 IPv6 for RTC
* - Values: IPv6 / true (auto-detect), false (disable)
* - Default: true
* @param {Number} options.rtcMinPort Min RTC port
* - Default: 10000
* @param {Number} options.rtcMaxPort Max RTC port
* - Default: 59999
* @param {String} options.dtlsCertificateFile Path to DTLS certificate
* @param {String} options.dtlsPrivateKeyFile Path to DTLS private key
* Create a Server instance.
*
* @param {Object} [options]
* @param {number} [options.numWorkers=HOST_NUM_CORES] - Number of child workers.
* @param {string} [options.logLevel='debug'] - Log level. Valid values are
* 'debug', 'warn', 'error'.
* @param {string|boolean} [options.rtcListenIPv4=true] - IPv4 for RTC. Valid
* values are a IPv4, `true` (auto-detect) and `false` (disabled).
* @param {string|boolean} [options.rtcListenIPv6=true] - IPv6 for RTC. Valid
* values are a IPv6, `true` (auto-detect) and `false` (disabled).
* @param {number} [options.rtcMinPort=10000] - Minimun RTC port.
* @param {number} [options.rtcMaxPort=59999] - Maximum RTC port.
* @param {string} [options.dtlsCertificateFile] - Path to DTLS certificate.
* @param {string} [options.dtlsPrivateKeyFile] - Path to DTLS private key.
*
* @return {Server}
*/
Server: function(options)
......@@ -45,7 +41,7 @@ module.exports =
let server = new Server(options);
// Store the Server instance and remove it when closed
// Store the Server instance and remove it when closed.
servers.add(server);
server.on('close', () => servers.delete(server));
......@@ -53,24 +49,24 @@ module.exports =
},
/**
* Export mediasoup custom errors
* Export mediasoup custom errors.
*/
errors: errors,
/**
* Export the extra module
* Export the extra module.
*/
extra: extra
};
// On process exit close all the Servers
// On process exit close all the Servers.
process.on('exit', () =>
{
servers.forEach((server) => server.close());
});
// Log 'unhandledRejection' events
// NOTE: Those events could be fired due to user code or other running libraries
// Log 'unhandledRejection' events.
// NOTE: Those events could be fired due to user code or other running libraries.
process.on('unhandledRejection', (reason) =>
{
if (reason instanceof Error)
......
......@@ -13,7 +13,9 @@
"url": "https://github.com/ibc/mediasoup/issues"
},
"homepage": "https://github.com/ibc/mediasoup/",
"os": [ "!win32" ],
"os": [
"!win32"
],
"engines": {
"node": ">=4.0.0"
},
......@@ -33,7 +35,7 @@
"gulp-shell": "^0.5.2",
"jshint": "^2.9.1",
"jshint-stylish": "^2.1.0",
"tap": "^5.6.0"
"tap": "^5.7.1"
},
"scripts": {
"test": "gulp test",
......
......@@ -78,7 +78,7 @@ tap.test('rtpReceiver.receive() with valid `rtpParameters` must succeed', { time
return Promise.all(
[
transport.dump()
.then((data) =>
.then(() =>
{
t.pass('transport.dump() succeeded');
// TODO: Enable when done
......
......@@ -34,7 +34,7 @@ tap.test('alice, bob and carol create RtpReceivers and expect RtpSenders', { tim
{
name : 'opus',
payloadType : 101,
clockRate : 90000,
clockRate : 90000
}
],
encodings :
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论