mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Handle peers connection close
This commit is contained in:
parent
a5061dd7ef
commit
9deba36bcd
@ -204,8 +204,10 @@ class CallWindow extends CustomEvents {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
if(this.mainPeer)
|
if(this.mainPeer) {
|
||||||
this.mainPeer.destroy();
|
this.mainPeer.destroy();
|
||||||
|
delete this.mainPeer;
|
||||||
|
}
|
||||||
|
|
||||||
// Destroy peer connections
|
// Destroy peer connections
|
||||||
for(const el of this.peersEls)
|
for(const el of this.peersEls)
|
||||||
@ -232,19 +234,13 @@ class CallWindow extends CustomEvents {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a user from a call
|
* Remove a member connection
|
||||||
*
|
*
|
||||||
* @param {number} userID The ID of the target user
|
* @param {number} userID Target user ID
|
||||||
*/
|
*/
|
||||||
async RemoveMember(userID) {
|
async RemoveMemberConnection(userID) {
|
||||||
|
|
||||||
// Remove user name
|
|
||||||
const el = this.membersArea.querySelector("[data-call-member-name-id=\""+userID+"\"]")
|
|
||||||
if(el)
|
|
||||||
el.remove()
|
|
||||||
|
|
||||||
// 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);
|
||||||
@ -259,6 +255,22 @@ class CallWindow extends CustomEvents {
|
|||||||
this.peersEls.get(userID).destroy()
|
this.peersEls.get(userID).destroy()
|
||||||
this.peersEls.delete(userID)
|
this.peersEls.delete(userID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a user from a call
|
||||||
|
*
|
||||||
|
* @param {number} userID The ID of the target user
|
||||||
|
*/
|
||||||
|
async RemoveMember(userID) {
|
||||||
|
|
||||||
|
// Remove user name
|
||||||
|
const el = this.membersArea.querySelector("[data-call-member-name-id=\""+userID+"\"]")
|
||||||
|
if(el)
|
||||||
|
el.remove()
|
||||||
|
|
||||||
|
this.RemoveMemberConnection(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -353,6 +365,12 @@ class CallWindow extends CustomEvents {
|
|||||||
console.log("mainPeer stream", stream)
|
console.log("mainPeer stream", stream)
|
||||||
alert("Stream on main peer!!!")
|
alert("Stream on main peer!!!")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.mainPeer.on("close", () => {
|
||||||
|
console.log("Connection to main peer was closed.")
|
||||||
|
if(this.mainPeer)
|
||||||
|
this.Close(true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -389,11 +407,18 @@ class CallWindow extends CustomEvents {
|
|||||||
this.addVideoStream(peerID, false, stream)
|
this.addVideoStream(peerID, false, stream)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
peer.on("close", () => {
|
||||||
|
console.info("Connection to peer " + peerID + " closed");
|
||||||
|
this.RemoveMemberConnection(peerID)
|
||||||
|
})
|
||||||
|
|
||||||
// Request an offer from proxy
|
// Request an offer from proxy
|
||||||
await ws("calls/request_offer", {
|
await ws("calls/request_offer", {
|
||||||
callID: this.callID,
|
callID: this.callID,
|
||||||
peerID: peerID,
|
peerID: peerID,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log(peer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user