-
Notifications
You must be signed in to change notification settings - Fork 2
/
genice.js
30 lines (24 loc) · 912 Bytes
/
genice.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
/**
### `rtc-core/genice`
Respond appropriately to options that are passed to packages like
`rtc-quickconnect` and trigger a `callback` (error first) with iceServer
values.
The function looks for either of the following keys in the options, in
the following order or precedence:
1. `ice` - this can either be an array of ice server values or a generator
function (in the same format as this function). If this key contains a
value then any servers specified in the `iceServers` key (2) will be
ignored.
2. `iceServers` - an array of ice server values.
**/
module.exports = function(opts, callback) {
var ice = (opts || {}).ice;
var iceServers = (opts || {}).iceServers;
if (typeof ice == 'function') {
return ice(opts, callback);
}
else if (Array.isArray(ice)) {
return callback(null, [].concat(ice));
}
callback(null, [].concat(iceServers || []));
};