From ac6ee1bfa3b8f482d5d70740939ca502076f3531 Mon Sep 17 00:00:00 2001 From: Astagor Date: Mon, 4 May 2020 19:31:50 +0200 Subject: [PATCH 1/3] Added limit for maximum number of users in a single room --- app/src/RoomClient.js | 7 +++++++ app/src/actions/roomActions.js | 6 ++++++ app/src/components/JoinDialog.js | 15 +++++++++++++++ app/src/reducers/room.js | 6 ++++++ app/src/translations/cn.json | 1 + app/src/translations/cs.json | 1 + app/src/translations/de.json | 1 + app/src/translations/dk.json | 1 + app/src/translations/el.json | 1 + app/src/translations/en.json | 1 + app/src/translations/es.json | 1 + app/src/translations/fr.json | 1 + app/src/translations/hr.json | 1 + app/src/translations/hu.json | 1 + app/src/translations/it.json | 1 + app/src/translations/nb.json | 1 + app/src/translations/pl.json | 1 + app/src/translations/pt.json | 1 + app/src/translations/ro.json | 1 + app/src/translations/tr.json | 1 + app/src/translations/uk.json | 1 + server/config/config.example.js | 2 ++ server/lib/Room.js | 8 ++++++++ 23 files changed, 61 insertions(+) diff --git a/app/src/RoomClient.js b/app/src/RoomClient.js index 8dbc9d14..8a502be1 100644 --- a/app/src/RoomClient.js +++ b/app/src/RoomClient.js @@ -1963,6 +1963,13 @@ export default class RoomClient break; } + case 'overRoomLimit': + { + store.dispatch(roomActions.setOverRoomLimit(true)); + + break; + } + case 'roomReady': { const { turnServers } = notification.data; diff --git a/app/src/actions/roomActions.js b/app/src/actions/roomActions.js index 30ce37ca..b90bf1bf 100644 --- a/app/src/actions/roomActions.js +++ b/app/src/actions/roomActions.js @@ -40,6 +40,12 @@ export const setSignInRequired = (signInRequired) => payload : { signInRequired } }); +export const setOverRoomLimit = (overRoomLimit) => + ({ + type : 'SET_OVER_ROOM_LIMIT', + payload : { overRoomLimit } + }); + export const setAccessCode = (accessCode) => ({ type : 'SET_ACCESS_CODE', diff --git a/app/src/components/JoinDialog.js b/app/src/components/JoinDialog.js index a8493dbf..8a2bc236 100644 --- a/app/src/components/JoinDialog.js +++ b/app/src/components/JoinDialog.js @@ -83,6 +83,10 @@ const styles = (theme) => green : { color : 'rgba(0, 153, 0, 1)' + }, + red : + { + color : 'rgba(153, 0, 0, 1)' } }); @@ -281,6 +285,16 @@ const JoinDialog = ({ }} fullWidth /> + {!room.inLobby && room.overRoomLimit && + + + + } @@ -419,6 +433,7 @@ export default withRoomContext(connect( return ( prev.room.inLobby === next.room.inLobby && prev.room.signInRequired === next.room.signInRequired && + prev.room.overRoomLimit === next.room.overRoomLimit && prev.settings.displayName === next.settings.displayName && prev.me.displayNameInProgress === next.me.displayNameInProgress && prev.me.loginEnabled === next.me.loginEnabled && diff --git a/app/src/reducers/room.js b/app/src/reducers/room.js index f4bc6ab9..a4bbfb4f 100644 --- a/app/src/reducers/room.js +++ b/app/src/reducers/room.js @@ -6,6 +6,7 @@ const initialState = locked : false, inLobby : false, signInRequired : false, + overRoomLimit : false, // access code to the room if locked and joinByAccessCode == true accessCode : '', // if true: accessCode is a possibility to open the room @@ -88,7 +89,12 @@ const room = (state = initialState, action) => return { ...state, signInRequired }; } + case 'SET_OVER_ROOM_LIMIT': + { + const { overRoomLimit } = action.payload; + return { ...state, overRoomLimit }; + } case 'SET_ACCESS_CODE': { const { accessCode } = action.payload; diff --git a/app/src/translations/cn.json b/app/src/translations/cn.json index e82e9d50..a5ac918f 100644 --- a/app/src/translations/cn.json +++ b/app/src/translations/cn.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/app/src/translations/cs.json b/app/src/translations/cs.json index 1a2b3c59..0acac2ac 100644 --- a/app/src/translations/cs.json +++ b/app/src/translations/cs.json @@ -58,6 +58,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/app/src/translations/de.json b/app/src/translations/de.json index a6f6ac21..eec3d7c1 100644 --- a/app/src/translations/de.json +++ b/app/src/translations/de.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": "Du bist stummgeschalted, Halte die SPACE-Taste um zu sprechen", diff --git a/app/src/translations/dk.json b/app/src/translations/dk.json index 40273636..58bd0fc2 100644 --- a/app/src/translations/dk.json +++ b/app/src/translations/dk.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/app/src/translations/el.json b/app/src/translations/el.json index 5f93f42c..4db8158e 100644 --- a/app/src/translations/el.json +++ b/app/src/translations/el.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/app/src/translations/en.json b/app/src/translations/en.json index 8fe4fa11..a40ba8f7 100644 --- a/app/src/translations/en.json +++ b/app/src/translations/en.json @@ -59,6 +59,7 @@ "room.raisedHand": "{displayName} raised their hand", "room.loweredHand": "{displayName} put their hand down", "room.extraVideo": "Extra video", + "room.overRoomLimit": null, "me.mutedPTT": "You are muted, hold down SPACE-BAR to talk", diff --git a/app/src/translations/es.json b/app/src/translations/es.json index d73506c1..85899ae5 100644 --- a/app/src/translations/es.json +++ b/app/src/translations/es.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/app/src/translations/fr.json b/app/src/translations/fr.json index f884c36c..0126ede4 100644 --- a/app/src/translations/fr.json +++ b/app/src/translations/fr.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/app/src/translations/hr.json b/app/src/translations/hr.json index eb9d08e0..14baba40 100644 --- a/app/src/translations/hr.json +++ b/app/src/translations/hr.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": "Utišani ste, pritisnite i držite SPACE tipku za razgovor", diff --git a/app/src/translations/hu.json b/app/src/translations/hu.json index f25b06a3..2648c60e 100644 --- a/app/src/translations/hu.json +++ b/app/src/translations/hu.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/app/src/translations/it.json b/app/src/translations/it.json index d027e7a5..d8f990c7 100644 --- a/app/src/translations/it.json +++ b/app/src/translations/it.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/app/src/translations/nb.json b/app/src/translations/nb.json index e803bdae..935841bd 100644 --- a/app/src/translations/nb.json +++ b/app/src/translations/nb.json @@ -59,6 +59,7 @@ "room.raisedHand": "{displayName} rakk opp hånden", "room.loweredHand": "{displayName} tok ned hånden", "room.extraVideo": "Ekstra video", + "room.overRoomLimit": null, "me.mutedPTT": "Du er dempet, hold nede SPACE for å snakke", diff --git a/app/src/translations/pl.json b/app/src/translations/pl.json index 399f7881..abe6fb46 100644 --- a/app/src/translations/pl.json +++ b/app/src/translations/pl.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/app/src/translations/pt.json b/app/src/translations/pt.json index d66d8da6..214b6207 100644 --- a/app/src/translations/pt.json +++ b/app/src/translations/pt.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/app/src/translations/ro.json b/app/src/translations/ro.json index b37b36a0..95c79520 100644 --- a/app/src/translations/ro.json +++ b/app/src/translations/ro.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/app/src/translations/tr.json b/app/src/translations/tr.json index d3d20e36..4cbad15a 100644 --- a/app/src/translations/tr.json +++ b/app/src/translations/tr.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/app/src/translations/uk.json b/app/src/translations/uk.json index dcb3c7d4..933fda0e 100644 --- a/app/src/translations/uk.json +++ b/app/src/translations/uk.json @@ -59,6 +59,7 @@ "room.raisedHand": null, "room.loweredHand": null, "room.extraVideo": null, + "room.overRoomLimit": null, "me.mutedPTT": null, diff --git a/server/config/config.example.js b/server/config/config.example.js index 6ff279a8..8af36156 100644 --- a/server/config/config.example.js +++ b/server/config/config.example.js @@ -247,6 +247,8 @@ module.exports = // When truthy, the room will be open to all users when as long as there // are allready users in the room activateOnHostJoin : true, + // When set, maxUsersPerRoom defines how many users can join a single room. If not set, there is not limit. + // maxUsersPerRoom : 20, // Mediasoup settings mediasoup : { diff --git a/server/lib/Room.js b/server/lib/Room.js index 9200be90..bbd0cba1 100644 --- a/server/lib/Room.js +++ b/server/lib/Room.js @@ -177,6 +177,9 @@ class Room extends EventEmitter peer.roles.some((role) => accessFromRoles.BYPASS_ROOM_LOCK.includes(role)) ) this._peerJoining(peer); + else if ('maxUsersPerRoom' in config &&(this._getJoinedPeers().length + this._lobby.peerList().length) >= config.maxUsersPerRoom) { + this._handleOverRoomLimit(peer); + } else if (this._locked) this._parkPeer(peer); else @@ -188,6 +191,11 @@ class Room extends EventEmitter } } + _handleOverRoomLimit(peer) + { + this._notification(peer.socket, 'overRoomLimit'); + } + _handleGuest(peer) { if (config.activateOnHostJoin && !this.checkEmpty()) From ab5893dbdf6bb9e26f689bc98c31fd78bf15628d Mon Sep 17 00:00:00 2001 From: Astagor Date: Tue, 5 May 2020 08:02:11 +0200 Subject: [PATCH 2/3] Fixed lint --- app/src/components/JoinDialog.js | 16 ++++++++-------- app/src/reducers/room.js | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/components/JoinDialog.js b/app/src/components/JoinDialog.js index 8a2bc236..3308622d 100644 --- a/app/src/components/JoinDialog.js +++ b/app/src/components/JoinDialog.js @@ -286,14 +286,14 @@ const JoinDialog = ({ fullWidth /> {!room.inLobby && room.overRoomLimit && - - - + + + } diff --git a/app/src/reducers/room.js b/app/src/reducers/room.js index a4bbfb4f..6d47d42a 100644 --- a/app/src/reducers/room.js +++ b/app/src/reducers/room.js @@ -6,7 +6,7 @@ const initialState = locked : false, inLobby : false, signInRequired : false, - overRoomLimit : false, + overRoomLimit : false, // access code to the room if locked and joinByAccessCode == true accessCode : '', // if true: accessCode is a possibility to open the room From 7e6795986efe166bd9e1c2a085178a8f6bbe763c Mon Sep 17 00:00:00 2001 From: Astagor Date: Tue, 5 May 2020 08:08:35 +0200 Subject: [PATCH 3/3] Fixed lint server --- server/lib/Room.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/lib/Room.js b/server/lib/Room.js index d43bf245..ec8febf7 100644 --- a/server/lib/Room.js +++ b/server/lib/Room.js @@ -214,7 +214,8 @@ class Room extends EventEmitter peer.roles.some((role) => accessFromRoles.BYPASS_ROOM_LOCK.includes(role)) ) this._peerJoining(peer); - else if ('maxUsersPerRoom' in config &&(this._getJoinedPeers().length + this._lobby.peerList().length) >= config.maxUsersPerRoom) { + else if ('maxUsersPerRoom' in config &&(this._getJoinedPeers().length + this._lobby.peerList().length) >= config.maxUsersPerRoom) + { this._handleOverRoomLimit(peer); } else if (this._locked)