-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (23 loc) · 1.05 KB
/
index.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
/**
# rtc-pluggable-signaller
By using `rtc-pluggable-signaller` in your code, you provide the ability
for your package to customize which signalling client it uses (and
thus have significant control) over how signalling operates in your
environment.
## How it Works
The pluggable signaller looks in the provided `opts` for a `signaller`
attribute. If the value of this attribute is a string, then it is
assumed that you wish to use the default
[`rtc-signaller`](https://github.com/rtc-io/rtc-signaller) in your
package. If, however, it is not a string value then it will be passed
straight back as the signaller (assuming that you have provided an
object that is compliant with the rtc.io signalling API).
**/
module.exports = function(opts) {
var signaller = (opts || {}).signaller;
var messenger = (opts || {}).messenger || require('rtc-switchboard-messenger');
if (typeof signaller == 'string' || (signaller instanceof String)) {
return require('rtc-signaller')(messenger(signaller, opts), opts);
}
return signaller;
};