Skip to content

Commit

Permalink
Only emit TrackStreamStateChanged events on changed stream state (#1199)
Browse files Browse the repository at this point in the history
* Only emit TrackStreamStateChanged events on changed stream state

* Create strong-ladybugs-notice.md
  • Loading branch information
lukasIO authored Oct 7, 2024
1 parent d1e797e commit c5b9888
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/strong-ladybugs-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Only emit TrackStreamStateChanged events on changed stream state
19 changes: 11 additions & 8 deletions src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1493,14 +1493,17 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
if (!pub || !pub.track) {
return;
}
pub.track.streamState = Track.streamStateFromProto(streamState.state);
participant.emit(ParticipantEvent.TrackStreamStateChanged, pub, pub.track.streamState);
this.emitWhenConnected(
RoomEvent.TrackStreamStateChanged,
pub,
pub.track.streamState,
participant,
);
const newStreamState = Track.streamStateFromProto(streamState.state);
if (newStreamState !== pub.track.streamState) {
pub.track.streamState = newStreamState;
participant.emit(ParticipantEvent.TrackStreamStateChanged, pub, pub.track.streamState);
this.emitWhenConnected(
RoomEvent.TrackStreamStateChanged,
pub,
pub.track.streamState,
participant,
);
}
});
};

Expand Down

0 comments on commit c5b9888

Please sign in to comment.