-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathscripts.js
More file actions
70 lines (63 loc) · 1.58 KB
/
scripts.js
File metadata and controls
70 lines (63 loc) · 1.58 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
const uitoolkit = window.UIToolkit;
var sessionContainer = document.getElementById("sessionContainer");
var authEndpoint = "http://localhost:4000";
var config = {
videoSDKJWT: "",
sessionName: "test",
userName: "JavaScript",
sessionPasscode: "123",
featuresOptions: {
virtualBackground: {
enable: true,
virtualBackgrounds: [
{
url: "https://images.unsplash.com/photo-1715490187538-30a365fa05bd?q=80&w=1945&auto=format&fit=crop",
},
],
},
},
};
var role = 1;
window.getVideoSDKJWT = getVideoSDKJWT;
function getVideoSDKJWT() {
document.getElementById("join-flow").style.display = "none";
fetch(authEndpoint, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
sessionName: config.sessionName,
role: role,
videoWebRtcMode: 1,
}),
})
.then((response) => {
return response.json();
})
.then((data) => {
if (data.signature) {
console.log(data.signature);
config.videoSDKJWT = data.signature;
joinSession();
} else {
console.log(data);
}
})
.catch((error) => {
console.log(error);
});
}
function joinSession() {
uitoolkit.joinSession(sessionContainer, config);
uitoolkit.onSessionClosed(sessionClosed);
uitoolkit.onSessionDestroyed(sessionDestroyed);
}
var sessionClosed = () => {
console.log("session closed");
document.getElementById("join-flow").style.display = "block";
};
var sessionDestroyed = () => {
console.log("session destroyed");
uitoolkit.destroy();
};