Added limit for maximum number of users in a single room
This commit is contained in:
@@ -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 :
|
||||
{
|
||||
|
||||
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user