[mirotalksfu] - improvements
هذا الالتزام موجود في:
@@ -2187,9 +2187,8 @@ class RoomClient {
|
|||||||
// ####################################################
|
// ####################################################
|
||||||
|
|
||||||
peerAction(from_peer_name, id, action, emit = true, broadcast = false) {
|
peerAction(from_peer_name, id, action, emit = true, broadcast = false) {
|
||||||
let peer_id = id;
|
const words = id.split('___');
|
||||||
const words = peer_id.split('___');
|
let peer_id = words[0];
|
||||||
peer_id = words[0];
|
|
||||||
|
|
||||||
if (emit) {
|
if (emit) {
|
||||||
let data = {
|
let data = {
|
||||||
@@ -2199,34 +2198,17 @@ class RoomClient {
|
|||||||
broadcast: broadcast,
|
broadcast: broadcast,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (participantsCount === 1) return;
|
if (!this.thereIsParticipants()) {
|
||||||
|
this.userLog('info', 'No participants detected', 'top-end');
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.confirmPeerAction(action, data);
|
this.confirmPeerAction(action, data);
|
||||||
} else {
|
} else {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'eject':
|
case 'eject':
|
||||||
if (peer_id === this.peer_id || broadcast) {
|
if (peer_id === this.peer_id || broadcast) {
|
||||||
this.sound(action);
|
this.sound(action);
|
||||||
let timerInterval;
|
this.peerActionProgress(from_peer_name, 'Will eject you from the room after', 5000, action);
|
||||||
Swal.fire({
|
|
||||||
allowOutsideClick: false,
|
|
||||||
background: swalBackground,
|
|
||||||
title: from_peer_name,
|
|
||||||
html: 'Will eject you from the room after <b style="color: red;"></b> milliseconds.',
|
|
||||||
timer: 5000,
|
|
||||||
timerProgressBar: true,
|
|
||||||
didOpen: () => {
|
|
||||||
Swal.showLoading();
|
|
||||||
const b = Swal.getHtmlContainer().querySelector('b');
|
|
||||||
timerInterval = setInterval(() => {
|
|
||||||
b.textContent = Swal.getTimerLeft();
|
|
||||||
}, 100);
|
|
||||||
},
|
|
||||||
willClose: () => {
|
|
||||||
clearInterval(timerInterval);
|
|
||||||
},
|
|
||||||
}).then(() => {
|
|
||||||
this.exit();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'mute':
|
case 'mute':
|
||||||
@@ -2257,9 +2239,41 @@ class RoomClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
peerActionProgress(tt, msg, time, action = 'na') {
|
||||||
|
let timerInterval;
|
||||||
|
Swal.fire({
|
||||||
|
allowOutsideClick: false,
|
||||||
|
background: swalBackground,
|
||||||
|
title: tt,
|
||||||
|
html: msg + ' <b style="color: green;"></b> milliseconds.',
|
||||||
|
timer: time,
|
||||||
|
timerProgressBar: true,
|
||||||
|
didOpen: () => {
|
||||||
|
Swal.showLoading();
|
||||||
|
const b = Swal.getHtmlContainer().querySelector('b');
|
||||||
|
timerInterval = setInterval(() => {
|
||||||
|
b.textContent = Swal.getTimerLeft();
|
||||||
|
}, 100);
|
||||||
|
},
|
||||||
|
willClose: () => {
|
||||||
|
clearInterval(timerInterval);
|
||||||
|
},
|
||||||
|
}).then(() => {
|
||||||
|
switch (action) {
|
||||||
|
case 'refresh':
|
||||||
|
getRoomParticipants(true);
|
||||||
|
break;
|
||||||
|
case 'eject':
|
||||||
|
this.exit();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
confirmPeerAction(action, data) {
|
confirmPeerAction(action, data) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'eject':
|
case 'eject':
|
||||||
|
let ejectConfirmed = false;
|
||||||
let whoEject = data.broadcast ? 'All participants' : 'current participant';
|
let whoEject = data.broadcast ? 'All participants' : 'current participant';
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
background: swalBackground,
|
background: swalBackground,
|
||||||
@@ -2275,31 +2289,34 @@ class RoomClient {
|
|||||||
hideClass: {
|
hideClass: {
|
||||||
popup: 'animate__animated animate__fadeOutUp',
|
popup: 'animate__animated animate__fadeOutUp',
|
||||||
},
|
},
|
||||||
}).then((result) => {
|
})
|
||||||
if (result.isConfirmed) {
|
.then((result) => {
|
||||||
if (!data.broadcast) {
|
if (result.isConfirmed) {
|
||||||
let peer = this.getId(data.peer_id);
|
ejectConfirmed = true;
|
||||||
if (peer) {
|
if (!data.broadcast) {
|
||||||
peer.parentNode.removeChild(peer);
|
let peer = this.getId(data.peer_id);
|
||||||
participantsCount--;
|
if (peer) {
|
||||||
|
peer.parentNode.removeChild(peer);
|
||||||
|
participantsCount--;
|
||||||
|
refreshParticipantsCount(participantsCount);
|
||||||
|
this.socket.emit('peerAction', data);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let actionButton = this.getId(action + 'AllButton');
|
||||||
|
if (actionButton) actionButton.style.display = 'none';
|
||||||
|
participantsCount = 1;
|
||||||
refreshParticipantsCount(participantsCount);
|
refreshParticipantsCount(participantsCount);
|
||||||
this.socket.emit('peerAction', data);
|
this.socket.emit('peerAction', data);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
let actionButton = this.getId(action + 'AllButton');
|
|
||||||
if (actionButton) actionButton.style.display = 'none';
|
|
||||||
participantsCount = 1;
|
|
||||||
refreshParticipantsCount(participantsCount);
|
|
||||||
this.socket.emit('peerAction', data);
|
|
||||||
setTimeout(() => {
|
|
||||||
getRoomParticipants(true);
|
|
||||||
}, 6000);
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
});
|
.then(() => {
|
||||||
|
if (ejectConfirmed) this.peerActionProgress(action, 'In progress, wait...', 6000, 'refresh');
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case 'mute':
|
case 'mute':
|
||||||
case 'hide':
|
case 'hide':
|
||||||
|
let muteHideConfirmed = false;
|
||||||
let whoMuteHide = data.broadcast ? 'everyone' : 'current participant';
|
let whoMuteHide = data.broadcast ? 'everyone' : 'current participant';
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
background: swalBackground,
|
background: swalBackground,
|
||||||
@@ -2322,29 +2339,31 @@ class RoomClient {
|
|||||||
hideClass: {
|
hideClass: {
|
||||||
popup: 'animate__animated animate__fadeOutUp',
|
popup: 'animate__animated animate__fadeOutUp',
|
||||||
},
|
},
|
||||||
}).then((result) => {
|
})
|
||||||
if (result.isConfirmed) {
|
.then((result) => {
|
||||||
if (!data.broadcast) {
|
if (result.isConfirmed) {
|
||||||
switch (action) {
|
muteHideConfirmed = true;
|
||||||
case 'mute':
|
if (!data.broadcast) {
|
||||||
let peerAudioButton = this.getId(data.peer_id + '___pAudio');
|
switch (action) {
|
||||||
if (peerAudioButton) peerAudioButton.innerHTML = _PEER.audioOff;
|
case 'mute':
|
||||||
break;
|
let peerAudioButton = this.getId(data.peer_id + '___pAudio');
|
||||||
case 'hide':
|
if (peerAudioButton) peerAudioButton.innerHTML = _PEER.audioOff;
|
||||||
let peerVideoButton = this.getId(data.peer_id + '___pVideo');
|
break;
|
||||||
if (peerVideoButton) peerVideoButton.innerHTML = _PEER.videoOff;
|
case 'hide':
|
||||||
|
let peerVideoButton = this.getId(data.peer_id + '___pVideo');
|
||||||
|
if (peerVideoButton) peerVideoButton.innerHTML = _PEER.videoOff;
|
||||||
|
}
|
||||||
|
this.socket.emit('peerAction', data);
|
||||||
|
} else {
|
||||||
|
let actionButton = this.getId(action + 'AllButton');
|
||||||
|
if (actionButton) actionButton.style.display = 'none';
|
||||||
|
this.socket.emit('peerAction', data);
|
||||||
}
|
}
|
||||||
this.socket.emit('peerAction', data);
|
|
||||||
} else {
|
|
||||||
let actionButton = this.getId(action + 'AllButton');
|
|
||||||
if (actionButton) actionButton.style.display = 'none';
|
|
||||||
this.socket.emit('peerAction', data);
|
|
||||||
setTimeout(() => {
|
|
||||||
getRoomParticipants(true);
|
|
||||||
}, 2000);
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
});
|
.then(() => {
|
||||||
|
if (muteHideConfirmed) this.peerActionProgress(action, 'In progress, wait...', 2000, 'refresh');
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم