-
Notifications
You must be signed in to change notification settings - Fork 189
Expose asynchronous API for connect #862
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
base: master
Are you sure you want to change the base?
Conversation
|
Could you please explain why a non-blocking API is better than using the existing API in a separate goroutine? (Also, I could be mistaken, but I think that the new API is asynchronous rather than nonblocking.) |
|
API symmetry is one reason, the DTLS API makes a clear distinction between setting up the connection and not returning until the connection is up ( |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #862 +/- ##
==========================================
+ Coverage 88.11% 88.22% +0.11%
==========================================
Files 43 44 +1
Lines 5427 5479 +52
==========================================
+ Hits 4782 4834 +52
+ Misses 449 448 -1
- Partials 196 197 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
af458bc to
7411e97
Compare
|
No objection, even though I tend to prefer using multiple goroutines to asynchronous APIs, which I find error-prone. I've looked at the first commit, and it looks good to me. Minor nits:
Have you already submitted the code where you use the new API? May I have a look? I don't understand why the second commit is being submitted as part of the same PR, but in any case I'm not competent to review it. |
0299f73 to
e27a9c3
Compare
adding `StartDial`, `StartAccept` and `AwaitConnect` methods which allow more control than `Start` and `Accept` This will allow the peer connection API to start DTLS before the ICE connection is established, see pion/webrtc#3335
e27a9c3 to
187b3ea
Compare
|
Thanks. The first commit looks good to me. |
Done, thank you!
https://github.com/fippo/pion-webrtc/blob/snap-sped/icetransport.go#L93
githubs continued lack of support for stacked PRs / branches... should vanish once the other PR is merged |
Thanks. While you wait for this commit to land, you could do something like the following, which would decouple the two commits and avoid the issues with stacked branches: type connErr struct {
conn *Conn
err error
}
func (a *Agent) StartDial(remoteUfrag, remotePwd string) (chan connErr) {
ch := make(chan connErr)
go func() {
conn, err := a.Dial(context.Background(), remoteUfrag, remotePwd)
ch <- connErr{conn, err}
}()
return ch
}
func (a *Agent) AwaitConnect(ch chan connErr) (*Conn, error) {
ce <- ch
return ce.conn, ce.err
} |
(ontop of #861)
This adds a nonblocking API for ICE that will allow the PeerConnection's
startTransportsto start ICE, not wait for ICE to connect and start DTLS so the DTLS handshake can be piggybacked into the STUN messages earlier.