Rady to connect to other peers

This commit is contained in:
Pierre HUBERT 2020-04-11 14:50:37 +02:00
parent 8febe2a523
commit 59cd9e0fb4
3 changed files with 25 additions and 0 deletions

View File

@ -233,6 +233,11 @@ class UserWebSocket {
SendEvent("newCallSignal", msg.data);
break;
case "call_peer_ready":
SendEvent("callPeerReady", msg.data);
break;
default:
console.error("WS Unspported kind of message!", msg);
break;

View File

@ -97,6 +97,13 @@ document.addEventListener("newCallSignal", (e) => {
OpenConversations.get(detail.callID).NewSignal(detail.peerID, detail.data)
});
document.addEventListener("callPeerReady", (e) => {
const detail = e.detail;
if(OpenConversations.has(detail.callID))
OpenConversations.get(detail.callID).PeerReady(detail.peerID)
})
document.addEventListener("wsClosed", () => {
// Close all the current conversations

View File

@ -96,6 +96,11 @@ class CallWindow extends CustomEvents {
callID: this.conv.ID
})
// Start to connect to ready pears
for(const user of currMembersList)
if(user.userID != userID() && user.ready)
await this.PeerReady(user.userID)
// Start to stream audio & video
await this.startStreaming();
@ -195,6 +200,10 @@ class CallWindow extends CustomEvents {
convID: this.conv.ID
})
if(this.mainPeer)
this.mainPeer.destroy();
if(propagate)
this.emitEvent("close");
}
@ -325,6 +334,10 @@ class CallWindow extends CustomEvents {
});
}
async PeerReady(peerID) {
alert("Start to receive " + peerID)
}
/**
* Handles new signals
*