Skip to content

Commit

Permalink
[mirotalksfu] - refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpejic85 committed Jan 7, 2025
1 parent 52dbc9b commit 97e1e29
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
34 changes: 17 additions & 17 deletions app/src/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dev dependencies: {
* @license For commercial or closed source, contact us at [email protected] or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - [email protected]
* @version 1.6.86
* @version 1.6.87
*
*/

Expand Down Expand Up @@ -1478,7 +1478,7 @@ function startServer() {

const isPresenter = peer_token
? is_presenter
: await isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
: isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);

const peer = room.getPeer(socket.id);

Expand Down Expand Up @@ -1859,7 +1859,7 @@ function startServer() {
break;
case 'ejectAll':
const { peer_name, peer_uuid } = data;
const isPresenter = await isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
const isPresenter = isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
if (!isPresenter) return;
break;
case 'peerAudio':
Expand All @@ -1881,7 +1881,7 @@ function startServer() {

const data = checkXSS(dataObject);

const isPresenter = await isPeerPresenter(socket.room_id, socket.id, data.peer_name, data.peer_uuid);
const isPresenter = isPeerPresenter(socket.room_id, socket.id, data.peer_name, data.peer_uuid);

const room = getRoom(socket);

Expand Down Expand Up @@ -1997,7 +1997,7 @@ function startServer() {
];

if (presenterActions.some((v) => data.action === v)) {
const isPresenter = await isPeerPresenter(
const isPresenter = isPeerPresenter(
socket.room_id,
socket.id,
data.from_peer_name,
Expand Down Expand Up @@ -2032,14 +2032,14 @@ function startServer() {
}
});

socket.on('updateRoomModerator', async (dataObject) => {
socket.on('updateRoomModerator', (dataObject) => {
if (!roomExists(socket)) return;

const data = checkXSS(dataObject);

const room = getRoom(socket);

const isPresenter = await isPeerPresenter(socket.room_id, socket.id, data.peer_name, data.peer_uuid);
const isPresenter = isPeerPresenter(socket.room_id, socket.id, data.peer_name, data.peer_uuid);

if (!isPresenter) return;

Expand All @@ -2061,14 +2061,14 @@ function startServer() {
}
});

socket.on('updateRoomModeratorALL', async (dataObject) => {
socket.on('updateRoomModeratorALL', (dataObject) => {
if (!roomExists(socket)) return;

const data = checkXSS(dataObject);

const room = getRoom(socket);

const isPresenter = await isPeerPresenter(socket.room_id, socket.id, data.peer_name, data.peer_uuid);
const isPresenter = isPeerPresenter(socket.room_id, socket.id, data.peer_name, data.peer_uuid);

if (!isPresenter) return;

Expand Down Expand Up @@ -2582,7 +2582,7 @@ function startServer() {

const data = checkXSS(dataObject);
const { peer_name, peer_uuid, file } = data;
const isPresenter = await isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
const isPresenter = isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
if (!isPresenter) return cb(false);

const room = getRoom(socket);
Expand Down Expand Up @@ -2626,7 +2626,7 @@ function startServer() {

const data = checkXSS(dataObject);
const { peer_name, peer_uuid, inputVideoURL } = data;
const isPresenter = await isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
const isPresenter = isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
if (!isPresenter) return cb(false);

const room = getRoom(socket);
Expand Down Expand Up @@ -2739,7 +2739,7 @@ function startServer() {
const { index, peer_name, peer_uuid } = checkXSS(data);

// Disable for now...
// const isPresenter = await isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
// const isPresenter = isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
// if (!isPresenter) return;

const room = getRoom(socket);
Expand Down Expand Up @@ -2789,14 +2789,14 @@ function startServer() {
room.broadCast(socket.id, 'editorUpdate', data);
});

socket.on('disconnect', async () => {
socket.on('disconnect', () => {
if (!roomExists(socket)) return;

const { room, peer } = getRoomAndPeer(socket);

const { peer_name, peer_uuid } = peer || {};

const isPresenter = await isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
const isPresenter = isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);

log.debug('[Disconnect] - peer name', peer_name);

Expand Down Expand Up @@ -2828,7 +2828,7 @@ function startServer() {
socket.room_id = null;
});

socket.on('exitRoom', async (_, callback) => {
socket.on('exitRoom', (_, callback) => {
if (!roomExists(socket)) {
return callback({
error: 'Not currently in a room',
Expand All @@ -2839,7 +2839,7 @@ function startServer() {

const { peer_name, peer_uuid } = peer || {};

const isPresenter = await isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);
const isPresenter = isPeerPresenter(socket.room_id, socket.id, peer_name, peer_uuid);

log.debug('Exit room', peer_name);

Expand Down Expand Up @@ -2984,7 +2984,7 @@ function startServer() {
return JSON.parse(JSON.stringify(value));
}

async function isPeerPresenter(room_id, peer_id, peer_name, peer_uuid) {
function isPeerPresenter(room_id, peer_id, peer_name, peer_uuid) {
try {
if (
config.presenters &&
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mirotalksfu",
"version": "1.6.86",
"version": "1.6.87",
"description": "WebRTC SFU browser-based video calls",
"main": "Server.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions public/js/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
* @license For commercial or closed source, contact us at [email protected] or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - [email protected]
* @version 1.6.86
* @version 1.6.87
*
*/

Expand Down Expand Up @@ -4702,7 +4702,7 @@ function showAbout() {
imageUrl: image.about,
customClass: { image: 'img-about' },
position: 'center',
title: 'WebRTC SFU v1.6.86',
title: 'WebRTC SFU v1.6.87',
html: `
<br />
<div id="about">
Expand Down
5 changes: 3 additions & 2 deletions public/js/RoomClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license For commercial or closed source, contact us at [email protected] or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - [email protected]
* @version 1.6.86
* @version 1.6.87
*
*/

Expand Down Expand Up @@ -1116,6 +1116,8 @@ class RoomClient {
}

handleDisconnect() {
window.localStorage.isReconnected = true;

console.log('Disconnected. Attempting to reconnect...');
this.exit(true);

Expand Down Expand Up @@ -1236,7 +1238,6 @@ class RoomClient {

ServerAway() {
this.sound('alert');
window.localStorage.isReconnected = true;
Swal.fire({
allowOutsideClick: false,
allowEscapeKey: false,
Expand Down

0 comments on commit 97e1e29

Please sign in to comment.