Prior to using the LeaveRoom method to close any existing socket channel connections, Peer A can send a message to the other Peers in the room using:


skylink.sendMessage({ action: "leaveRoom" })


The logic for this would need to be configured at the App level.


This message cannot be sent subsequent to calling the LeaveRoom method as there is no way for a disconnected peer to send a message to In Room Peers.

Following the calling of the LeaveRoom method, the PeerLeft event should be triggered when a Peer leaves the room:


skylink.on('peerLeft', function(peerId, peerInfo, isSelf) { var vid = document.getElementById(peerId); document.body.removeChild(vid); });
skylink.on("peerLeft", function (peerId, peerInfo, isSelf) {
if (!isSelf) {
var peerVideo = document.getElementById(peerId);
// Check if peerVideo exists first
if (peerVideo) {
document.getElementById("peersVideo").removeChild(peerVideo);
} else {
console.error("Peer video for " + peerId + " is not found.");
}
}
});



However, please note that if Peer A chooses to leave the room by closing the tab, the PeerLeft event will automatically be triggered.