-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (28 loc) · 903 Bytes
/
index.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
let hostID = document.getElementById("HOSTroomID");
let JOINroomID = document.getElementById("JOINroomID");
let MessageSend = document.getElementById("MessageSend");
let MessageGet = document.getElementById("MessageGet");
const webRTC = new simpleWebRTC(null ,{
onInit : id => hostID.value = id,
onMessage : data => getData(data),
remoteMedia : data => getMedia(data),
onSync : id => console.log('New Node :', id),
logger : data => console.log(data),
video : true,
audio : true
});
const getData = data =>{
MessageGet.value = MessageGet.value + data.data + '\n';
if(data.data == 'call'){
webRTC.beginCall(data.id);
}
}
const getMedia = list => {
document.getElementById("v2").srcObject = list[0].stream;
}
const joinRoom = () => {
webRTC.joinID(JOINroomID.value);
}
const sendMessage = () =>{
webRTC.sendData(MessageSend.value);
}