Skip to content

Commit

Permalink
Account for reconnect when adding track (#366)
Browse files Browse the repository at this point in the history
* handle reconnect promise in onTrackAdded

* changeset
  • Loading branch information
lukasIO committed Jul 29, 2022
1 parent d040aff commit b52e7b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-sloths-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'livekit-client': patch
---

Handle reconnect case in onTrackAdded
4 changes: 2 additions & 2 deletions src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
// at that time, ICE connectivity has not been established so the track is not
// technically subscribed.
// We'll defer these events until when the room is connected or eventually disconnected.
if (this.connectFuture) {
this.connectFuture.promise.then(() => {
if (this.connectFuture || this.reconnectFuture) {
Promise.allSettled([this.connectFuture?.promise, this.reconnectFuture?.promise]).then(() => {
this.onTrackAdded(mediaTrack, stream, receiver);
});
return;
Expand Down

0 comments on commit b52e7b3

Please sign in to comment.