Add timestamps to various peer parameters.

auto_join_3.3
Håvar Aambø Fosstveit 2020-05-04 15:14:47 +02:00
parent 69a988200d
commit f70ed01e7e
1 changed files with 39 additions and 5 deletions

View File

@ -23,10 +23,14 @@ class Peer extends EventEmitter
this._joined = false; this._joined = false;
this._joinedTimestamp = null;
this._inLobby = false; this._inLobby = false;
this._authenticated = false; this._authenticated = false;
this._authenticatedTimestamp = null;
this._roles = [ userRoles.NORMAL ]; this._roles = [ userRoles.NORMAL ];
this._displayName = false; this._displayName = false;
@ -39,6 +43,8 @@ class Peer extends EventEmitter
this._raisedHand = false; this._raisedHand = false;
this._raisedHandTimestamp = null;
this._transports = new Map(); this._transports = new Map();
this._producers = new Map(); this._producers = new Map();
@ -135,9 +141,18 @@ class Peer extends EventEmitter
set joined(joined) set joined(joined)
{ {
joined ?
this._joinedTimestamp = Date.now() :
this._joinedTimestamp = null;
this._joined = joined; this._joined = joined;
} }
get joinedTimestamp()
{
return this._joinedTimestamp;
}
get inLobby() get inLobby()
{ {
return this._inLobby; return this._inLobby;
@ -157,6 +172,10 @@ class Peer extends EventEmitter
{ {
if (authenticated !== this._authenticated) if (authenticated !== this._authenticated)
{ {
authenticated ?
this._authenticatedTimestamp = Date.now() :
this._authenticatedTimestamp = null;
const oldAuthenticated = this._authenticated; const oldAuthenticated = this._authenticated;
this._authenticated = authenticated; this._authenticated = authenticated;
@ -165,6 +184,11 @@ class Peer extends EventEmitter
} }
} }
get authenticatedTimestamp()
{
return this._authenticatedTimestamp;
}
get roles() get roles()
{ {
return this._roles; return this._roles;
@ -231,9 +255,18 @@ class Peer extends EventEmitter
set raisedHand(raisedHand) set raisedHand(raisedHand)
{ {
raisedHand ?
this._raisedHandTimestamp = Date.now() :
this._raisedHandTimestamp = null;
this._raisedHand = raisedHand; this._raisedHand = raisedHand;
} }
get raisedHandTimestamp()
{
return this._raisedHandTimestamp;
}
get transports() get transports()
{ {
return this._transports; return this._transports;
@ -337,7 +370,8 @@ class Peer extends EventEmitter
displayName : this.displayName, displayName : this.displayName,
picture : this.picture, picture : this.picture,
roles : this.roles, roles : this.roles,
raisedHand : this.raisedHand raisedHand : this.raisedHand,
raisedHandTimestamp : this.raisedHandTimestamp
}; };
return peerInfo; return peerInfo;