Cleanup and handling of events.

This commit is contained in:
Håvar Aambø Fosstveit
2019-10-22 15:30:04 +02:00
parent 0299e5f661
commit 38cf88aa62
4 changed files with 18 additions and 52 deletions
-26
View File
@@ -34,32 +34,6 @@ class Lobby extends EventEmitter
this._peers = {};
}
authCallback(data, roomLocked)
{
logger.debug('authCallback() | [data:"%o", roomLocked:"%s"]', data, roomLocked);
const {
peerId,
displayName,
picture
} = data;
const peer = this._peers[peerId];
if (peer)
{
this._notification(peer.socket, 'auth', {
displayName : displayName,
picture : picture
});
if (!roomLocked)
{
this.promotePeer(peerId);
}
}
}
peerList()
{
logger.info('peerList()');
+9 -21
View File
@@ -179,9 +179,9 @@ class Room extends EventEmitter
logStatus()
{
logger.info(
'logStatus() [room id:"%s", peers:%s]',
'logStatus() [room id:"%s", peers:%o]',
this._roomId,
this._peers.size
this._peers
);
}
@@ -241,28 +241,16 @@ class Room extends EventEmitter
return this._locked;
}
authCallback(data)
peerAuthenticated(peerid)
{
logger.debug('authCallback()');
logger.debug('peerAuthenticated() | [peerId:"%s"]', peerId);
const {
peerId,
displayName,
picture
} = data;
const peer = this._peers[peerId];
if (peer)
if (!this._locked)
{
this._notification(peer.socket, 'auth', {
displayName : displayName,
picture : picture
});
}
else if (this._lobby.hasPeer(peerId))
{
this._lobby.authCallback(data, this._locked);
if (!Boolean(this._peers[peerid]))
{
this._lobby.promotePeer(peerId);
}
}
}