Fix logic for joining rooms.
parent
4b0c17c698
commit
b108fbac87
|
|
@ -40,6 +40,10 @@ module.exports =
|
||||||
// If false, there is no difference between guests and signed-in
|
// If false, there is no difference between guests and signed-in
|
||||||
// users when joining.
|
// users when joining.
|
||||||
requireSignInToAccess : true,
|
requireSignInToAccess : true,
|
||||||
|
// This flag has no effect when requireSignInToAccess is false
|
||||||
|
// When truthy, the room will be open to all users when the first
|
||||||
|
// authenticated user has already joined the room.
|
||||||
|
activateOnHostJoin : true,
|
||||||
// Mediasoup settings
|
// Mediasoup settings
|
||||||
mediasoup :
|
mediasoup :
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -126,20 +126,37 @@ class Room extends EventEmitter
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ( this._locked )
|
else if (this._locked)
|
||||||
{
|
{
|
||||||
this._parkPeer(peer);
|
this._parkPeer(peer);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else if ( Boolean(config.requireSignInToAccess) && this.checkEmpty())
|
else
|
||||||
|
{
|
||||||
|
peer.authenticated ?
|
||||||
|
this._peerJoining(peer) :
|
||||||
|
this._handleGuest(peer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_handleGuest(peer)
|
||||||
|
{
|
||||||
|
if (config.requireSignInToAccess)
|
||||||
|
{
|
||||||
|
if (config.activateOnHostJoin && !this.checkEmpty())
|
||||||
|
{
|
||||||
|
this._peerJoining(peer);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
this._parkPeer(peer);
|
this._parkPeer(peer);
|
||||||
this._notification(peer.socket, 'signInRequired');
|
this._notification(peer.socket, 'signInRequired');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
this._peerJoining(peer);
|
this._peerJoining(peer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_handleLobby()
|
_handleLobby()
|
||||||
{
|
{
|
||||||
|
|
@ -255,7 +272,7 @@ class Room extends EventEmitter
|
||||||
if (this._closed)
|
if (this._closed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.checkEmpty())
|
if (this.checkEmpty() && this._lobby.checkEmpty())
|
||||||
{
|
{
|
||||||
logger.info(
|
logger.info(
|
||||||
'Room deserted for some time, closing the room [roomId:"%s"]',
|
'Room deserted for some time, closing the room [roomId:"%s"]',
|
||||||
|
|
@ -270,7 +287,7 @@ class Room extends EventEmitter
|
||||||
// checks both room and lobby
|
// checks both room and lobby
|
||||||
checkEmpty()
|
checkEmpty()
|
||||||
{
|
{
|
||||||
return (this._peers.size == 0) && (this._lobby.checkEmpty());
|
return this._peers.size === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_parkPeer(parkPeer)
|
_parkPeer(parkPeer)
|
||||||
|
|
@ -341,7 +358,7 @@ class Room extends EventEmitter
|
||||||
|
|
||||||
// If this is the last Peer in the room and
|
// If this is the last Peer in the room and
|
||||||
// lobby is empty, close the room after a while.
|
// lobby is empty, close the room after a while.
|
||||||
if (this.checkEmpty())
|
if (this.checkEmpty() && this._lobby.checkEmpty())
|
||||||
{
|
{
|
||||||
this.selfDestructCountdown();
|
this.selfDestructCountdown();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue