-
Notifications
You must be signed in to change notification settings - Fork 0
/
joinroom.js
38 lines (34 loc) · 1.33 KB
/
joinroom.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
35
36
37
38
var kaltura = require('kaltura-client');
function joinMeetingRoom(resourceId,firstName,lastName,email,done) {
const config = new kaltura.Configuration();
config.serviceUrl = process.env.KALTURA_SERVICE_URL;
const client = new kaltura.Client(config);
const apiSecret = process.env.KALTURA_ADMIN_SECRET
const partnerId = process.env.KALTURA_PARTNER_ID
const expiry = 86400;
const type = kaltura.enums.SessionType.USER;
// Set priveleges parameter for Kaltura Session (KS) generation.
// For userContextual role:
// 0 = admin
// 3 = guest
// Mandatory fields: role, userContextualRole, resourceId (or eventId)
let userContextualRole = "0";
let privileges = "role:viewerRole,userContextualRole:" + userContextualRole +
",resourceId:" + resourceId + ",firstName:" + firstName + ",lastName:"+lastName+",email:" + email;
// Generate KS
kaltura.services.session.start(
apiSecret,
email, // this is the user ID which uniquely identifies the user
type,
partnerId,
expiry,
privileges)
.execute(client)
.then(result => {
// Pass the generated url back to caller in order for it to be rendered
let roomUrl = "https://" + partnerId + ".kaf.kaltura.com/virtualEvent/launch?ks=" + result;
console.log("JOIN URL: "+ roomUrl);
done(roomUrl);
});
}
module.exports = joinMeetingRoom