* Stop all local and remote tracks then leave the channel.
*/
asyncfunctionleave(){
for(trackNameinlocalTracks){
vartrack=localTracks[trackName];
...
...
@@ -127,32 +102,17 @@ async function leave() {
localTracks[trackName]=undefined;
}
}
// Remove remote users and player views.
remoteUsers={};
// leave the channel
if(!client){
return
}
awaitclient.leave();
}
/*
* Add a user who has subscribed to the live channel to the local interface.
*
* @param {IAgoraRTCRemoteUser} user - The {@link https://docs.agora.io/en/Voice/API%20Reference/web_ng/interfaces/iagorartcremoteuser.html| remote user} to add.
* @param {trackMediaType - The {@link https://docs.agora.io/en/Voice/API%20Reference/web_ng/interfaces/itrack.html#trackmediatype | media type} to add.
*/
functionhandleUserPublished(user,mediaType){
constid=user.uid;
remoteUsers[id]=user;
$("#remote-uid").val(id)
}
/*
* Remove the user specified from the channel in the local interface.
*
* @param {string} user - The {@link https://docs.agora.io/en/Voice/API%20Reference/web_ng/interfaces/iagorartcremoteuser.html| remote user} to remove.
*/
functionhandleUserUnpublished(user,mediaType){
if(mediaType==="video"){
constid=user.uid;
...
...
@@ -161,23 +121,23 @@ function handleUserUnpublished(user, mediaType) {