Skip to content

Commit

Permalink
Resolve join promise after API channel ready (2) (#192)
Browse files Browse the repository at this point in the history
* Revert "Resolve `join` promise after API channel ready (#185)" (#190)

This reverts commit 4d1d436.

* Resolve `join` promise after API channel ready

Previously, the (implicit) promise returned by `join` would resolve
after establishing the transports, but before the API data channel was
attached.  This meant there was a small window of time where the API
data channel was not ready, and trying to use the subscriber API during
that time would fail silently.

This change returns a promise that does not resolve until after the API
channel is established.

* Set Ion connector's `sfu` before join

It's possible for some of the callbacks to fire while awaiting
`sfu.join`, and those callbacks may need to access the connector's `sfu`
property.  So we should set it before we start the join.

Co-authored-by: adwpc <[email protected]>
  • Loading branch information
kevinmcconnell and adwpc authored Apr 20, 2021
1 parent 4d1d436 commit 1a757e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ export class IonConnector {
this.ondatachannel?.call(this, ev);
sfu.onspeaker = (ev: string[]) => this.onspeaker?.call(this, ev);

await sfu.join(this._sid, this._uid);

this._sfu = sfu;

await sfu.join(this._sid, this._uid);
}
});

Expand Down

0 comments on commit 1a757e3

Please sign in to comment.