mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-26 05:49:22 +00:00
Start to send signals
This commit is contained in:
parent
3bda79cc8b
commit
ca5dd4b34c
@ -15,6 +15,7 @@ class CallWindow extends CustomEvents {
|
|||||||
constructor(conv) {
|
constructor(conv) {
|
||||||
super()
|
super()
|
||||||
this.conv = conv;
|
this.conv = conv;
|
||||||
|
this.callID = conv.ID;
|
||||||
this.construct(conv);
|
this.construct(conv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,11 +74,18 @@ class CallWindow extends CustomEvents {
|
|||||||
convID: this.conv.ID
|
convID: this.conv.ID
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Get call configuration
|
||||||
|
this.callsConfig = await ws("calls/config");
|
||||||
|
|
||||||
// Get the list of members of the call
|
// Get the list of members of the call
|
||||||
const currMembersList = await ws("calls/members", {
|
const currMembersList = await ws("calls/members", {
|
||||||
callID: this.conv.ID
|
callID: this.conv.ID
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Start to stream audio & video
|
||||||
|
await this.startStreaming();
|
||||||
|
|
||||||
|
|
||||||
// Apply this list of user
|
// Apply this list of user
|
||||||
for(const user of currMembersList)
|
for(const user of currMembersList)
|
||||||
if(user != userID())
|
if(user != userID())
|
||||||
@ -208,4 +216,49 @@ class CallWindow extends CustomEvents {
|
|||||||
el.remove()
|
el.remove()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get call configuration
|
||||||
|
*/
|
||||||
|
callConfig() {
|
||||||
|
return {
|
||||||
|
iceServers: this.callsConfig.iceServers.map((e) => {return {urls: e}})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add video stream to the user
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
addVideoStream(video) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start to send this client audio & video
|
||||||
|
*/
|
||||||
|
async startStreaming() {
|
||||||
|
|
||||||
|
// First, query user media
|
||||||
|
const stream = await navigator.mediaDevices.getUserMedia({
|
||||||
|
video: true,
|
||||||
|
audio: true
|
||||||
|
})
|
||||||
|
|
||||||
|
this.mainPeer = new SimplePeer({
|
||||||
|
initiator: true,
|
||||||
|
trickle: true, // Allow exchange of multiple ice candidates
|
||||||
|
stream: stream,
|
||||||
|
config: this.callConfig()
|
||||||
|
})
|
||||||
|
|
||||||
|
this.mainPeer.on("signal", data => {
|
||||||
|
ws("call/signal", {
|
||||||
|
callID: this.callID,
|
||||||
|
peerID: userID(),
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user