Merge pull request #293 from Astagor/room_limit

Added limit for maximum number of users in a single room
This commit is contained in:
Håvar Aambø Fosstveit
2020-05-05 09:25:20 +02:00
committed by GitHub
23 changed files with 62 additions and 0 deletions
+2
View File
@@ -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,
// Room size before spreading to new router
routerScaleSize : 20,
// Mediasoup settings
+9
View File
@@ -214,6 +214,10 @@ 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
@@ -225,6 +229,11 @@ class Room extends EventEmitter
}
}
_handleOverRoomLimit(peer)
{
this._notification(peer.socket, 'overRoomLimit');
}
_handleGuest(peer)
{
if (config.activateOnHostJoin && !this.checkEmpty())