mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-25 21:39:21 +00:00
Update
This commit is contained in:
parent
143e0a0c87
commit
95d2540cb4
@ -55,6 +55,10 @@
|
|||||||
margin: 0px 5px;
|
margin: 0px 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.call-window .members-area span.ready {
|
||||||
|
color: rgb(1, 218, 1);
|
||||||
|
}
|
||||||
|
|
||||||
.call-window .videos-area {
|
.call-window .videos-area {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
@ -99,6 +99,11 @@ class CallWindow extends CustomEvents {
|
|||||||
callID: this.conv.ID
|
callID: this.conv.ID
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Apply this list of user
|
||||||
|
for(const user of currMembersList)
|
||||||
|
if(user.userID != userID())
|
||||||
|
await this.AddMember(user.userID)
|
||||||
|
|
||||||
// Start to connect to ready pears
|
// Start to connect to ready pears
|
||||||
for(const user of currMembersList)
|
for(const user of currMembersList)
|
||||||
if(user.userID != userID() && user.ready)
|
if(user.userID != userID() && user.ready)
|
||||||
@ -108,11 +113,6 @@ class CallWindow extends CustomEvents {
|
|||||||
await this.startStreaming();
|
await this.startStreaming();
|
||||||
|
|
||||||
|
|
||||||
// Apply this list of user
|
|
||||||
for(const user of currMembersList)
|
|
||||||
if(user.userID != userID())
|
|
||||||
await this.AddMember(user.userID)
|
|
||||||
|
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
notify("Could not initialize call!", "danger");
|
notify("Could not initialize call!", "danger");
|
||||||
@ -234,6 +234,16 @@ class CallWindow extends CustomEvents {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name element of a member
|
||||||
|
*
|
||||||
|
* @param {number} userID The ID of the user to get
|
||||||
|
* @return {HTMLElement|null}
|
||||||
|
*/
|
||||||
|
getMemberNameEl(userID) {
|
||||||
|
return this.membersArea.querySelector("[data-call-member-name-id=\""+userID+"\"]");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a member connection
|
* Remove a member connection
|
||||||
*
|
*
|
||||||
@ -241,6 +251,10 @@ class CallWindow extends CustomEvents {
|
|||||||
*/
|
*/
|
||||||
async RemoveMemberConnection(userID) {
|
async RemoveMemberConnection(userID) {
|
||||||
|
|
||||||
|
const el = this.getMemberNameEl(userID)
|
||||||
|
if(el)
|
||||||
|
el.classList.remove("ready")
|
||||||
|
|
||||||
// Remove video (if any)
|
// Remove video (if any)
|
||||||
if(this.videoEls.has(userID)) {
|
if(this.videoEls.has(userID)) {
|
||||||
const el = this.videoEls.get(userID);
|
const el = this.videoEls.get(userID);
|
||||||
@ -266,7 +280,7 @@ class CallWindow extends CustomEvents {
|
|||||||
async RemoveMember(userID) {
|
async RemoveMember(userID) {
|
||||||
|
|
||||||
// Remove user name
|
// Remove user name
|
||||||
const el = this.membersArea.querySelector("[data-call-member-name-id=\""+userID+"\"]")
|
const el = this.getMemberNameEl(userID)
|
||||||
if(el)
|
if(el)
|
||||||
el.remove()
|
el.remove()
|
||||||
|
|
||||||
@ -291,6 +305,11 @@ class CallWindow extends CustomEvents {
|
|||||||
*/
|
*/
|
||||||
addVideoStream(peerID, muted, stream) {
|
addVideoStream(peerID, muted, stream) {
|
||||||
|
|
||||||
|
// Remove any previous video stream
|
||||||
|
if(this.videoEls.has(peerID)) {
|
||||||
|
this.videoEls.get(peerID).remove()
|
||||||
|
}
|
||||||
|
|
||||||
const videoEl = document.createElement(stream.getVideoTracks().length > 0 ? "video" : "audio");
|
const videoEl = document.createElement(stream.getVideoTracks().length > 0 ? "video" : "audio");
|
||||||
this.videosArea.appendChild(videoEl)
|
this.videosArea.appendChild(videoEl)
|
||||||
|
|
||||||
@ -367,11 +386,16 @@ class CallWindow extends CustomEvents {
|
|||||||
alert("Stream on main peer!!!")
|
alert("Stream on main peer!!!")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
DO NOT DO THIS !!! On configuration change it would close
|
||||||
|
the call window...
|
||||||
|
|
||||||
this.mainPeer.on("close", () => {
|
this.mainPeer.on("close", () => {
|
||||||
console.log("Connection to main peer was closed.")
|
console.log("Connection to main peer was closed.")
|
||||||
if(this.mainPeer)
|
if(this.mainPeer)
|
||||||
this.Close(false);
|
this.Close(false);
|
||||||
});
|
});*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -380,6 +404,18 @@ class CallWindow extends CustomEvents {
|
|||||||
* @param {number} peerID Target peer ID
|
* @param {number} peerID Target peer ID
|
||||||
*/
|
*/
|
||||||
async PeerReady(peerID) {
|
async PeerReady(peerID) {
|
||||||
|
|
||||||
|
// Mark the peer as ready
|
||||||
|
const el = this.getMemberNameEl(peerID)
|
||||||
|
if(el)
|
||||||
|
el.classList.add("ready")
|
||||||
|
|
||||||
|
|
||||||
|
// Remove any previous connection
|
||||||
|
if(this.peersEls.has(peerID)) {
|
||||||
|
this.peersEls.get(peerID).destroy()
|
||||||
|
}
|
||||||
|
|
||||||
const peer = new SimplePeer({
|
const peer = new SimplePeer({
|
||||||
initiator: false,
|
initiator: false,
|
||||||
trickle: true, // Allow exchange of multiple ice candidates
|
trickle: true, // Allow exchange of multiple ice candidates
|
||||||
|
Loading…
Reference in New Issue
Block a user