forked from jurisv/WebRTC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opentok.js
31 lines (25 loc) · 986 Bytes
/
opentok.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
var OpenTok = require('opentok'); // OpenTok WebRTC service calls http://www.tokbox.com
module.exports = function(nconf){
var _opentok = {},
opentok,
ApiKey = process.env.OpenTokApi,
ApiSecret = process.env.OpenTokSecret;
//Use ENV Vars first then use server-config
if(!ApiKey && nconf.get('adminsettings').serviceprovider.firebase.SecretKey != undefined) {
ApiKey = nconf.get('adminsettings').serviceprovider.opentok.ApiKey;
ApiSecret = nconf.get('adminsettings').serviceprovider.opentok.SecretKey;
opentok = new OpenTok(ApiKey, ApiSecret);
}else{
opentok = new OpenTok(ApiKey, ApiSecret);
}
_opentok = {
getOpenTokSessionId: function (callback) {
opentok.createSession(function (err, session) {
if (err) return console.log(err);
callback(null, session.sessionId);
}
);
}
};
return _opentok;
};