Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register engine events on localParticipant when updated #480

Merged
merged 8 commits into from
Oct 20, 2022

Conversation

lukasIO
Copy link
Contributor

@lukasIO lukasIO commented Oct 20, 2022

We didn't register the events after setting localParticipant.engine previously.
Error surfaced when calling recreateEngine instead of createEngine during connect, where the localparticipant wouldn't notice that the engine had changed.

@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2022

🦋 Changeset detected

Latest commit: cba4e6a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@lukasIO lukasIO requested a review from boks1971 October 20, 2022 15:53
src/room/Room.ts Outdated
@@ -233,15 +233,17 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
}
if (this.state === ConnectionState.Reconnecting) {
log.info('Reconnection attempt replaced by new connection attempt');
// make sure we close and recreate the existing engine in order to get rid of any potentially ongoing reconnection attempts
this.recreateEngine();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this fall through? It is calling createEngine below through a connectFn promise it looks like.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guess that is okay as createEngine checks for this.engine?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, the wording on createEngine isn't ideal as it won't actually do anything if the engine already exists.
Maybe renaming createEngine to something like ensureEngine would be the way to go?

Copy link
Contributor

@boks1971 boks1971 Oct 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use the name like maybeCreateEngine on server side for such uses. ensureEngine also works. Actually, createEngine works as well. Just that the code segment was a bit confusing. It calls recreateEngine. A few lines down, there is createEngine (although that is actually inside a function variable which is used way down the function, I actually kept expanding that function in the review to see how far down that gets :-) )

@lukasIO lukasIO merged commit 1452210 into main Oct 20, 2022
@lukasIO lukasIO deleted the lukas/fix-setting-engine branch October 20, 2022 17:52
@github-actions github-actions bot mentioned this pull request Oct 20, 2022
max-b pushed a commit to Invisv-Privacy/client-sdk-js that referenced this pull request Dec 5, 2022
* Register engine events on localParticipant when updated

* changeset

* add comment

* remove debug code

* remove log

* remove log

* rename createEngine, make codepath easier to follow

* set connection state as early as possible
max-b pushed a commit to Invisv-Privacy/client-sdk-js that referenced this pull request Dec 5, 2022
* Register engine events on localParticipant when updated

* changeset

* add comment

* remove debug code

* remove log

* remove log

* rename createEngine, make codepath easier to follow

* set connection state as early as possible
max-b pushed a commit to Invisv-Privacy/client-sdk-js that referenced this pull request Dec 9, 2022
* Register engine events on localParticipant when updated

* changeset

* add comment

* remove debug code

* remove log

* remove log

* rename createEngine, make codepath easier to follow

* set connection state as early as possible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants