[mirotalksfu] - improve getRoomParticipants
هذا الالتزام موجود في:
@@ -150,6 +150,19 @@ access to use this app.
|
|||||||
</div>
|
</div>
|
||||||
<div id="remoteAudios"></div>
|
<div id="remoteAudios"></div>
|
||||||
|
|
||||||
|
<section id="participants" class="fadein center hidden">
|
||||||
|
<header id="participantsHeader" class="participants-header">
|
||||||
|
<div id="participantsTitle" class="participants-header-title"></div>
|
||||||
|
<div class="participants-header-options">
|
||||||
|
<button id="participantsRefreshBtn" class="fas fa-sync-alt"></button>
|
||||||
|
<button id="participantsCloseBtn" class="fas fa-times"></button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<div id="roomParticipants"></div>
|
||||||
|
</main>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section id="chatRoom" class="chat-room center fadein">
|
<section id="chatRoom" class="chat-room center fadein">
|
||||||
<section id="msger" class="msger">
|
<section id="msger" class="msger">
|
||||||
<header id="chatHeader" class="chat-header">
|
<header id="chatHeader" class="chat-header">
|
||||||
|
|||||||
@@ -527,6 +527,31 @@ button:hover {
|
|||||||
# Room Participants
|
# Room Participants
|
||||||
--------------------------------------------------------------*/
|
--------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#participants {
|
||||||
|
z-index: 17;
|
||||||
|
position: absolute;
|
||||||
|
margin: auto;
|
||||||
|
padding: 10px;
|
||||||
|
min-width: 320px;
|
||||||
|
background: var(--body-bg);
|
||||||
|
border-radius: 10px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.participants-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
background: rgb(0, 0, 0);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
color: #666;
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
|
|
||||||
|
.participants-header-title {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
#roomParticipants {
|
#roomParticipants {
|
||||||
max-height: 480px;
|
max-height: 480px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|||||||
@@ -4,6 +4,13 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
|
|||||||
|
|
||||||
const RoomURL = window.location.href;
|
const RoomURL = window.location.href;
|
||||||
|
|
||||||
|
const swalBackground = 'linear-gradient(to left, #1f1e1e, #000000)';
|
||||||
|
const swalImageUrl = '../images/pricing-illustration.svg';
|
||||||
|
|
||||||
|
const url = {
|
||||||
|
ipLookup: 'https://extreme-ip-lookup.com/json/',
|
||||||
|
};
|
||||||
|
|
||||||
const _PEER = {
|
const _PEER = {
|
||||||
audioOn: '<i class="fas fa-microphone"></i>',
|
audioOn: '<i class="fas fa-microphone"></i>',
|
||||||
audioOff: '<i style="color: red;" class="fas fa-microphone-slash"></i>',
|
audioOff: '<i style="color: red;" class="fas fa-microphone-slash"></i>',
|
||||||
@@ -14,12 +21,7 @@ const _PEER = {
|
|||||||
ejectPeer: '<i class="fas fa-times"></i>',
|
ejectPeer: '<i class="fas fa-times"></i>',
|
||||||
};
|
};
|
||||||
|
|
||||||
const swalBackground = 'linear-gradient(to left, #1f1e1e, #000000)';
|
let participantsCount = 0;
|
||||||
const swalImageUrl = '../images/pricing-illustration.svg';
|
|
||||||
|
|
||||||
const url = {
|
|
||||||
ipLookup: 'https://extreme-ip-lookup.com/json/',
|
|
||||||
};
|
|
||||||
|
|
||||||
let rc = null;
|
let rc = null;
|
||||||
let producer = null;
|
let producer = null;
|
||||||
@@ -54,6 +56,8 @@ function getRandomNumber(length) {
|
|||||||
function initClient() {
|
function initClient() {
|
||||||
if (!DetectRTC.isMobileDevice) {
|
if (!DetectRTC.isMobileDevice) {
|
||||||
setTippy('closeNavButton', 'Close', 'right');
|
setTippy('closeNavButton', 'Close', 'right');
|
||||||
|
setTippy('participantsRefreshBtn', 'Refresh', 'top');
|
||||||
|
setTippy('participantsCloseBtn', 'Close', 'top');
|
||||||
setTippy('chatMessage', 'Press enter to send', 'top-start');
|
setTippy('chatMessage', 'Press enter to send', 'top-start');
|
||||||
setTippy('chatSendButton', 'Send', 'top');
|
setTippy('chatSendButton', 'Send', 'top');
|
||||||
setTippy('chatEmojiButton', 'Emoji', 'top');
|
setTippy('chatEmojiButton', 'Emoji', 'top');
|
||||||
@@ -389,6 +393,7 @@ function roomIsReady() {
|
|||||||
setChatSize();
|
setChatSize();
|
||||||
} else {
|
} else {
|
||||||
rc.makeDraggable(chatRoom, chatHeader);
|
rc.makeDraggable(chatRoom, chatHeader);
|
||||||
|
rc.makeDraggable(participants, participantsHeader);
|
||||||
if (navigator.getDisplayMedia || navigator.mediaDevices.getDisplayMedia) {
|
if (navigator.getDisplayMedia || navigator.mediaDevices.getDisplayMedia) {
|
||||||
show(startScreenButton);
|
show(startScreenButton);
|
||||||
}
|
}
|
||||||
@@ -493,10 +498,10 @@ function stopRecordingTimer() {
|
|||||||
|
|
||||||
function handleButtons() {
|
function handleButtons() {
|
||||||
openNavButton.onclick = () => {
|
openNavButton.onclick = () => {
|
||||||
toggleNav();
|
rc.toggleNav();
|
||||||
};
|
};
|
||||||
closeNavButton.onclick = () => {
|
closeNavButton.onclick = () => {
|
||||||
toggleNav();
|
rc.toggleNav();
|
||||||
};
|
};
|
||||||
exitButton.onclick = () => {
|
exitButton.onclick = () => {
|
||||||
rc.exit();
|
rc.exit();
|
||||||
@@ -577,6 +582,12 @@ function handleButtons() {
|
|||||||
participantsButton.onclick = () => {
|
participantsButton.onclick = () => {
|
||||||
getRoomParticipants();
|
getRoomParticipants();
|
||||||
};
|
};
|
||||||
|
participantsRefreshBtn.onclick = () => {
|
||||||
|
getRoomParticipants(true);
|
||||||
|
};
|
||||||
|
participantsCloseBtn.onclick = () => {
|
||||||
|
toggleParticipants();
|
||||||
|
};
|
||||||
lockRoomButton.onclick = () => {
|
lockRoomButton.onclick = () => {
|
||||||
rc.roomAction('lock');
|
rc.roomAction('lock');
|
||||||
};
|
};
|
||||||
@@ -737,10 +748,6 @@ function handleRoomClientEvents() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleNav() {
|
|
||||||
control.classList.toggle('show');
|
|
||||||
}
|
|
||||||
|
|
||||||
// ####################################################
|
// ####################################################
|
||||||
// SHOW LOG
|
// SHOW LOG
|
||||||
// ####################################################
|
// ####################################################
|
||||||
@@ -777,36 +784,30 @@ async function sound(name) {
|
|||||||
// HANDLE PARTICIPANTS
|
// HANDLE PARTICIPANTS
|
||||||
// ####################################################
|
// ####################################################
|
||||||
|
|
||||||
async function getRoomParticipants() {
|
function toggleParticipants() {
|
||||||
|
let participants = rc.getId('participants');
|
||||||
|
participants.classList.toggle('show');
|
||||||
|
participants.style.top = '50%';
|
||||||
|
participants.style.left = '50%';
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getRoomParticipants(refresh = false) {
|
||||||
let room_info = await rc.getRoomInfo();
|
let room_info = await rc.getRoomInfo();
|
||||||
let peers = new Map(JSON.parse(room_info.peers));
|
let peers = new Map(JSON.parse(room_info.peers));
|
||||||
let table = await getParticipantsTable(peers);
|
let table = await getParticipantsTable(peers);
|
||||||
|
|
||||||
sound('open');
|
participantsCount = peers.size;
|
||||||
|
roomParticipants.innerHTML = table;
|
||||||
|
refreshParticipantsCount(participantsCount);
|
||||||
|
|
||||||
Swal.fire({
|
if (!refresh) {
|
||||||
background: swalBackground,
|
toggleParticipants();
|
||||||
position: 'center',
|
sound('open');
|
||||||
title: `Participants ${peers.size}`,
|
}
|
||||||
html: table,
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonText: `Refresh`,
|
|
||||||
cancelButtonText: `Close`,
|
|
||||||
showClass: {
|
|
||||||
popup: 'animate__animated animate__fadeInDown',
|
|
||||||
},
|
|
||||||
hideClass: {
|
|
||||||
popup: 'animate__animated animate__fadeOutUp',
|
|
||||||
},
|
|
||||||
}).then((result) => {
|
|
||||||
if (result.isConfirmed) {
|
|
||||||
getRoomParticipants();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getParticipantsTable(peers) {
|
async function getParticipantsTable(peers) {
|
||||||
let table = `<div id="roomParticipants">
|
let table = `
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
@@ -856,10 +857,14 @@ async function getParticipantsTable(peers) {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table += `</table></div>`;
|
table += `</table>`;
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refreshParticipantsCount(count) {
|
||||||
|
participantsTitle.innerHTML = `<i class="fas fa-users"></i> Participants ( ${count} )`;
|
||||||
|
}
|
||||||
|
|
||||||
// ####################################################
|
// ####################################################
|
||||||
// ABOUT
|
// ABOUT
|
||||||
// ####################################################
|
// ####################################################
|
||||||
|
|||||||
@@ -993,6 +993,10 @@ class RoomClient {
|
|||||||
// UTILITY
|
// UTILITY
|
||||||
// ####################################################
|
// ####################################################
|
||||||
|
|
||||||
|
toggleNav() {
|
||||||
|
this.getId('control').classList.toggle('show');
|
||||||
|
}
|
||||||
|
|
||||||
toggleDevices() {
|
toggleDevices() {
|
||||||
this.getId('settings').classList.toggle('show');
|
this.getId('settings').classList.toggle('show');
|
||||||
}
|
}
|
||||||
@@ -1468,6 +1472,8 @@ class RoomClient {
|
|||||||
|
|
||||||
if (emit) {
|
if (emit) {
|
||||||
if (!broadcast) {
|
if (!broadcast) {
|
||||||
|
if (participantsCount === 1) return;
|
||||||
|
|
||||||
const words = peer_id.split('__');
|
const words = peer_id.split('__');
|
||||||
peer_id = words[0];
|
peer_id = words[0];
|
||||||
|
|
||||||
@@ -1475,6 +1481,8 @@ class RoomClient {
|
|||||||
case 'eject':
|
case 'eject':
|
||||||
let peer = this.getId(peer_id);
|
let peer = this.getId(peer_id);
|
||||||
if (peer) peer.parentNode.removeChild(peer);
|
if (peer) peer.parentNode.removeChild(peer);
|
||||||
|
participantsCount--;
|
||||||
|
refreshParticipantsCount(participantsCount);
|
||||||
break;
|
break;
|
||||||
case 'mute':
|
case 'mute':
|
||||||
let peerAudioButton = this.getId(peer_id + '__audio');
|
let peerAudioButton = this.getId(peer_id + '__audio');
|
||||||
@@ -1485,19 +1493,23 @@ class RoomClient {
|
|||||||
if (peerVideoButton) peerVideoButton.innerHTML = _PEER.videoOff;
|
if (peerVideoButton) peerVideoButton.innerHTML = _PEER.videoOff;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (participantsCount === 1) return;
|
||||||
|
|
||||||
let actionButton = this.getId(action + 'AllButton');
|
let actionButton = this.getId(action + 'AllButton');
|
||||||
if (actionButton) actionButton.style.display = 'none';
|
if (actionButton) actionButton.style.display = 'none';
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'eject':
|
case 'eject':
|
||||||
|
participantsCount = 1;
|
||||||
|
refreshParticipantsCount(participantsCount);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getRoomParticipants();
|
getRoomParticipants(true);
|
||||||
}, 6000);
|
}, 6000);
|
||||||
break;
|
break;
|
||||||
case 'mute':
|
case 'mute':
|
||||||
case 'hide':
|
case 'hide':
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getRoomParticipants();
|
getRoomParticipants(true);
|
||||||
}, 2000);
|
}, 2000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,6 +150,20 @@ async function ngrokStart() {
|
|||||||
// ####################################################
|
// ####################################################
|
||||||
|
|
||||||
httpsServer.listen(config.listenPort, () => {
|
httpsServer.listen(config.listenPort, () => {
|
||||||
|
log.debug(
|
||||||
|
`%c
|
||||||
|
|
||||||
|
███████╗██╗ ██████╗ ███╗ ██╗ ███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔════╝██║██╔════╝ ████╗ ██║ ██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
███████╗██║██║ ███╗██╔██╗ ██║█████╗███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝
|
||||||
|
╚════██║██║██║ ██║██║╚██╗██║╚════╝╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗
|
||||||
|
███████║██║╚██████╔╝██║ ╚████║ ███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║
|
||||||
|
╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝ started...
|
||||||
|
|
||||||
|
`,
|
||||||
|
'font-family:monospace',
|
||||||
|
);
|
||||||
|
|
||||||
if (config.ngrokAuthToken !== '') {
|
if (config.ngrokAuthToken !== '') {
|
||||||
ngrokStart();
|
ngrokStart();
|
||||||
return;
|
return;
|
||||||
@@ -364,6 +378,7 @@ io.on('connection', (socket) => {
|
|||||||
|
|
||||||
socket.on('getRoomInfo', (_, cb) => {
|
socket.on('getRoomInfo', (_, cb) => {
|
||||||
cb(roomList.get(socket.room_id).toJson());
|
cb(roomList.get(socket.room_id).toJson());
|
||||||
|
log.debug('Send Room Info');
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('message', (data) => {
|
socket.on('message', (data) => {
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم