-
Notifications
You must be signed in to change notification settings - Fork 201
Wait for data channel to open
#67
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
Conversation
open
| if (publisher?.pc.iceConnectionState?.isConnected() == true) { | ||
| logger.warning('[$objectId] publisher is already connected'); | ||
| return; | ||
| // wait for data channel to open (if not already) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where it waits for open state of the data channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some callback to indicate data channel open failure if it fails for some reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitFor will throw a TimeoutException if it timeouts.
| throw UnexpectedStateException('Data channel is not ready'); | ||
| } | ||
| if (publisher?.pc.iceConnectionState?.isConnected() != true) { | ||
| logger.fine('Publisher is not connected...'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if there are a bunch of data channel messages sent by the app in this state? Are all of them becoming promises and get sent (promises resolved) when the data channel connects? Or are the messages just dropped on the floor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
promises should be pending until waitFor condition clears (received notification) or timeouts.
actually maybe there should be more checks to prevent negotiate() being called multiple times.. 🤔
(not sure how immediate the state changes to RTCIceConnectionStateChecking)
davidzhao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
In addition to publisher ice-connect,
this PR makes it wait until data channel is
openstate.