Fixed events on server when user logs in.
This commit is contained in:
+16
-2
@@ -192,7 +192,14 @@ class Peer extends EventEmitter
|
||||
|
||||
set displayName(displayName)
|
||||
{
|
||||
this._displayName = displayName;
|
||||
if (displayName !== this._displayName)
|
||||
{
|
||||
const oldDisplayName = this._displayName;
|
||||
|
||||
this._displayName = displayName;
|
||||
|
||||
this.emit('displayNameChanged', { oldDisplayName });
|
||||
}
|
||||
}
|
||||
|
||||
get picture()
|
||||
@@ -202,7 +209,14 @@ class Peer extends EventEmitter
|
||||
|
||||
set picture(picture)
|
||||
{
|
||||
this._picture = picture;
|
||||
if (picture !== this._picture)
|
||||
{
|
||||
const oldPicture = this._picture;
|
||||
|
||||
this._picture = picture;
|
||||
|
||||
this.emit('pictureChanged', { oldPicture });
|
||||
}
|
||||
}
|
||||
|
||||
get email()
|
||||
|
||||
@@ -339,6 +339,33 @@ class Room extends EventEmitter
|
||||
this.selfDestructCountdown();
|
||||
}
|
||||
});
|
||||
|
||||
peer.on('displayNameChanged', ({ oldDisplayName }) =>
|
||||
{
|
||||
// Ensure the Peer is joined.
|
||||
if (!peer.data.joined)
|
||||
throw new Error('Peer not yet joined');
|
||||
|
||||
// Spread to others
|
||||
this._notification(peer.socket, 'changeDisplayName', {
|
||||
peerId : peer.id,
|
||||
displayName : peer.displayName,
|
||||
oldDisplayName : oldDisplayName
|
||||
}, true);
|
||||
});
|
||||
|
||||
peer.on('pictureChanged', () =>
|
||||
{
|
||||
// Ensure the Peer is joined.
|
||||
if (!peer.data.joined)
|
||||
throw new Error('Peer not yet joined');
|
||||
|
||||
// Spread to others
|
||||
this._notification(peer.socket, 'changePicture', {
|
||||
peerId : peer.id,
|
||||
picture : peer.picture
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
||||
async _handleSocketRequest(peer, request, cb)
|
||||
|
||||
Reference in New Issue
Block a user