-
Notifications
You must be signed in to change notification settings - Fork 0
/
vcxroom.js
57 lines (49 loc) · 1.48 KB
/
vcxroom.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const vcxutil = require('./vcxutil');
const vcxroom = {};
// HTTP Request Options Creation
const options = {
host: 'api.enablex.io',
port: 443,
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${vcxutil.getBasicAuthToken()}`,
},
};
// Function: To create Token for a EnableX video Room
// Ref - https://developer.enablex.io/video-api-v1-6/server-api/rooms-route/#create-token
vcxroom.getToken = function getToken(details, callback) {
options.path = `/v1/rooms/${details.roomId}/tokens`;
options.method = 'POST';
vcxutil.connectServer(options, JSON.stringify(details), (status, data) => {
if (status === 'success') {
callback(status, data);
} else if (status === 'error') {
callback(status, data);
}
});
};
// Function: To create EnableX video Room
// Ref - https://developer.enablex.io/video-api-v1-6/server-api/rooms-route/#create-room
vcxroom.createRoom = function createRoom(callback) {
const roomMeta = {
name: 'Push notification service',
owner_ref: 'push service',
settings: {
scheduled: false,
adhoc: false,
participants: '4',
quality: 'SD',
auto_recording: false,
},
};
options.path = '/v1/rooms/';
options.method = 'POST';
vcxutil.connectServer(options, JSON.stringify(roomMeta), (status, data) => {
if (status === 'success') {
callback(status, data);
} else if (status === 'error') {
callback(status, data);
}
});
};
module.exports = vcxroom;