Small fixes.

master
Håvar Aambø Fosstveit 2019-10-24 00:08:49 +02:00
parent 77bbc53124
commit a8149d29d8
1 changed files with 12 additions and 7 deletions

View File

@ -102,11 +102,11 @@ class Room extends EventEmitter
// rooms selfdestruction sequence // rooms selfdestruction sequence
this._lobby.on('lobbyEmpty', () => this._lobby.on('lobbyEmpty', () =>
{ {
if ( this.checkEmpty() ) if (this.checkEmpty())
{ {
this.selfDestructCountdown(); this.selfDestructCountdown();
} }
}) });
this._chatHistory = []; this._chatHistory = [];
@ -166,7 +166,8 @@ class Room extends EventEmitter
selfDestructCountdown() selfDestructCountdown()
{ {
logger.debug('selfDestructCountdown() started') logger.debug('selfDestructCountdown() started');
setTimeout(() => setTimeout(() =>
{ {
if (this._closed) if (this._closed)
@ -179,7 +180,8 @@ class Room extends EventEmitter
this._roomId); this._roomId);
this.close(); this.close();
} }
else logger.debug('selfDestructCountdown() aborted; room is not empty!') else
logger.debug('selfDestructCountdown() aborted; room is not empty!');
}, 10000); }, 10000);
} }
@ -218,8 +220,10 @@ class Room extends EventEmitter
// checks both room and lobby // checks both room and lobby
checkEmpty() checkEmpty()
{ {
if (( Object.keys(this._peers).length == 0) && (this._lobby.checkEmpty())) return true if ((Object.keys(this._peers).length == 0) && (this._lobby.checkEmpty()))
else return false; return true;
else
return false;
} }
handleConnection({ peerId, consume, socket }) handleConnection({ peerId, consume, socket })
@ -355,7 +359,8 @@ class Room extends EventEmitter
delete this._peers[peer.id]; delete this._peers[peer.id];
// If this is the latest Peer in the room and lobby is empty, close the room after a while. // If this is the last Peer in the room and
// lobby is empty, close the room after a while.
if (this.checkEmpty()) if (this.checkEmpty())
{ {
this.selfDestructCountdown(); this.selfDestructCountdown();