Skip to content

Commit

Permalink
room: hook AttributesChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
nbsp authored Jul 26, 2024
1 parent 2573a57 commit d4071f5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
this.localParticipant
.on(ParticipantEvent.ParticipantMetadataChanged, this.onLocalParticipantMetadataChanged)
.on(ParticipantEvent.ParticipantNameChanged, this.onLocalParticipantNameChanged)
.on(ParticipantEvent.AttributesChanged, this.onAttributesChanged)
.on(ParticipantEvent.TrackMuted, this.onLocalTrackMuted)
.on(ParticipantEvent.TrackUnmuted, this.onLocalTrackUnmuted)
.on(ParticipantEvent.LocalTrackPublished, this.onLocalTrackPublished)
Expand Down Expand Up @@ -1294,6 +1295,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
this.localParticipant
.off(ParticipantEvent.ParticipantMetadataChanged, this.onLocalParticipantMetadataChanged)
.off(ParticipantEvent.ParticipantNameChanged, this.onLocalParticipantNameChanged)
.off(ParticipantEvent.AttributesChanged, this.onAttributesChanged)
.off(ParticipantEvent.TrackMuted, this.onLocalTrackMuted)
.off(ParticipantEvent.TrackUnmuted, this.onLocalTrackUnmuted)
.off(ParticipantEvent.LocalTrackPublished, this.onLocalTrackPublished)
Expand Down Expand Up @@ -1717,6 +1719,13 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
.on(ParticipantEvent.ParticipantNameChanged, (name) => {
this.emitWhenConnected(RoomEvent.ParticipantNameChanged, name, participant);
})
.on(ParticipantEvent.AttributesChanged, (changedAttributes: Record<string, string>) => {
this.emitWhenConnected(
RoomEvent.ParticipantAttributesChanged,
changedAttributes,
participant,
);
})
.on(ParticipantEvent.ConnectionQualityChanged, (quality: ConnectionQuality) => {
this.emitWhenConnected(RoomEvent.ConnectionQualityChanged, quality, participant);
})
Expand Down Expand Up @@ -1865,6 +1874,10 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
this.emit(RoomEvent.ParticipantNameChanged, name, this.localParticipant);
};

private onAttributesChanged = (changedAttributes: Record<string, string>) => {
this.emit(RoomEvent.ParticipantAttributesChanged, changedAttributes, this.localParticipant);
};

private onLocalTrackMuted = (pub: TrackPublication) => {
this.emit(RoomEvent.TrackMuted, pub, this.localParticipant);
};
Expand Down

0 comments on commit d4071f5

Please sign in to comment.