出现这种错误是因为用户不在当前频道中,可以通过以下代码解决:
client.on("peer-leave", function(evt) {
console.log("peer-leave", evt);
// If the current user is in the channel, remove the remote stream
var stream = evt.stream;
if (stream) {
var uid = stream.getId();
if (uid !== LOCAL_USER_ID) {
removeView(uid);
}
}
if (!remoteStreamList.length) {
$("#remote_video_div").html("");
}
// If the user who left the channel is not in the channel, remove the UID from remoteUsers
var leftUid = evt.uid;
var index = remoteUsers.indexOf(leftUid);
if (index !== -1) {
remoteUsers.splice(index, 1);
}
$("#remote_users").html(getRemoteUsersStr());
});