[mirotalksfu] - fix direct join with password

هذا الالتزام موجود في:
Miroslav Pejic
2022-10-18 08:25:25 +02:00
الأصل de6aa514e5
التزام c72b7549b9
3 ملفات معدلة مع 30 إضافات و3 حذوفات

عرض الملف

@@ -108,6 +108,10 @@ module.exports = class Room {
return this.peers;
}
getPeersCount() {
return this.peers.size;
}
toJson() {
return {
id: this.id,

عرض الملف

@@ -469,6 +469,16 @@ io.on('connection', (socket) => {
}
});
socket.on('getPeerCounts', async ({}, callback) => {
if (!roomList.has(socket.room_id)) return;
let peerCounts = roomList.get(socket.room_id).getPeersCount();
log.debug('Peer counts', { peerCounts: peerCounts });
callback({ peerCounts: peerCounts });
});
socket.on('roomAction', (data) => {
if (!roomList.has(socket.room_id)) return;

عرض الملف

@@ -3193,9 +3193,22 @@ class RoomClient {
switch (action) {
case 'lock':
if (room_password) {
data.password = room_password;
this.socket.emit('roomAction', data);
this.roomStatus(action);
this.socket
.request('getPeerCounts')
.then(
async function (data) {
// Only the presenter can lock the room
if (isPresenter || data.peerCounts == 1) {
isPresenter = true;
data.password = room_password;
this.socket.emit('roomAction', data);
this.roomStatus(action);
}
}.bind(this),
)
.catch((err) => {
console.log('Get peer counts:', err);
});
} else {
Swal.fire({
allowOutsideClick: false,