New version of lastN
This commit is contained in:
+27
-1
@@ -38,6 +38,9 @@ class Room extends EventEmitter
|
||||
|
||||
this._fileHistory = [];
|
||||
|
||||
this._lastN = [];
|
||||
|
||||
|
||||
this._io = io;
|
||||
|
||||
this._signalingPeers = new Map();
|
||||
@@ -123,6 +126,13 @@ class Room extends EventEmitter
|
||||
|
||||
const signalingPeer = { peerName : peerName, socket : socket };
|
||||
|
||||
const index = this._lastN.indexOf(peerName);
|
||||
|
||||
if (index === -1) // We don't have this peer, add to end
|
||||
{
|
||||
this._lastN.push(peerName);
|
||||
}
|
||||
|
||||
this._handleSignalingPeer(signalingPeer);
|
||||
}
|
||||
|
||||
@@ -140,6 +150,14 @@ class Room extends EventEmitter
|
||||
|
||||
this._currentActiveSpeaker = activePeer;
|
||||
|
||||
const index = this._lastN.indexOf(activePeer.name);
|
||||
|
||||
if (index > -1) // We have this speaker in the list, move to front
|
||||
{
|
||||
this._lastN.splice(index, 1);
|
||||
this._lastN = [activePeer.name].concat(this._lastN);
|
||||
}
|
||||
|
||||
const activeVideoProducer = activePeer.producers
|
||||
.find((producer) => producer.kind === 'video');
|
||||
|
||||
@@ -269,7 +287,8 @@ class Room extends EventEmitter
|
||||
null,
|
||||
{
|
||||
chatHistory : this._chatHistory,
|
||||
fileHistory : this._fileHistory
|
||||
fileHistory : this._fileHistory,
|
||||
lastN : this._lastN
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -325,6 +344,13 @@ class Room extends EventEmitter
|
||||
if (mediaPeer && !mediaPeer.closed)
|
||||
mediaPeer.close();
|
||||
|
||||
const index = this._lastN.indexOf(signalingPeer.peerName);
|
||||
|
||||
if (index > -1) // We have this peer in the list, remove
|
||||
{
|
||||
this._lastN.splice(index, 1);
|
||||
}
|
||||
|
||||
// If this is the latest peer in the room, close the room.
|
||||
// However wait a bit (for reconnections).
|
||||
setTimeout(() =>
|
||||
|
||||
Reference in New Issue
Block a user