-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
36 lines (30 loc) · 1.05 KB
/
test.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
'use strict';
const emitter = new EventEmitter();
const circuit = require('./circuit');
(async () => {
try {
await circuit.init();
const convIds = ['00ff03e5-89d7-4318-9ca4-e5f1e6a03178', '80ae9f44-a9a4-4b73-9d82-f40c3f4eb3ce'];
const promises = convIds.map(convId => circuit.startConference(convId, true));
// Leave conferences after a minute if nobody joined
convIds.forEach(convId => {
setTimeout(() => {
circuit.leaveConference(convId)
.catch(console.error);
}, 60000);
});
// Start conferences in parallel to showcase that multiple conferences
// can be started simultaneously
const res = await Promise.all(promises);
res.forEach((r, i) => {
if (!r) {
console.error(`Unable to start conference. convId: ${convIds[i]}`)
} else {
console.log(`Conference started. ${r.dialoutCount} users dialed out and at least two joined. convId: ${convIds[i]}, callId: ${r.callId}`)
}
});
await circuit.close();
} catch (err) {
console.error(err);
}
})();