-
Notifications
You must be signed in to change notification settings - Fork 24
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
add OnOpen() handler and fire it when appropriate #56
Conversation
67f07d4
to
89e1d60
Compare
@Sean-Der who would be best to review this? |
This commit implements an OnOpen() handler for a datachannel.DataChannel that is invoked when a DATA_CHANNEL_ACK is sent or received.
0fcf945
to
7fe0ff9
Compare
Codecov Report
@@ Coverage Diff @@
## master #56 +/- ##
==========================================
- Coverage 64.41% 58.84% -5.57%
==========================================
Files 4 4
Lines 222 243 +21
==========================================
Hits 143 143
- Misses 58 79 +21
Partials 21 21
Continue to review full report at Codecov.
|
This adds a test for DataChannel.OnOpen() ensuring that it is fired once when the DataChannel is open.
One issue to be considered is that processing of the DCEP ACK (leading to OnOpen handler firing) via Lines 186 to 204 in 2ae4a2f
For typical usage of pion/webrtc.Datachannel this will not be an issue as that package launches a read loop when the DataChannel is created, but may break detached dataChannel implementations where users would likely not start reading until OnOpen() fires: I think we need a separate goroutine to read the initial DCEP messages that datachannel.ReadDataChannel() blocks on. |
Oof really sorry @jwhited I am gonna get this merged tomorrow! I am the best person to review :) Things have been even busier then usual lately |
open := c.open | ||
c.mu.Unlock() | ||
|
||
if open { |
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.
@jwhited sorry about the delay working through this now!
I don't think we should have the if open
block, I just checked in the browser and OnOpen
events are not fired when setting the handler late.
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.
Beyond this LGTM! Would love to know if there is something I am missing, I can merge and delete this block myself though :)
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.
Thanks for taking a look!
I carried this over from pion/webrtc.Datachannel which always fires the handler. Removing this would cause the "Server" side to never fire as there's no way to set the handler before Server()
returns.
@Sean-Der would love your thoughts on #56 (comment) |
Good catch! It is a shame to add the extra complexity, I am not sure what the right answer is. I am tempted to call this a breaking change and have a flag Then we have break things in |
@Sean-Der I am needing fixes for this and pion/webrtc#1063 relatively soon. How can I help get these two merged and fixed? |
@Sean-Der Any movement on this? |
Merged in #122 |
Description
webrtc.DataChannel.OnOpen() will fire before a datachannel has been ack'd. This PR implements an OnOpen() handler for a datachannel.DataChannel that is invoked when a DATA_CHANNEL_ACK is sent or received. The intention is for this to bubble up to webrtc.DataChannel.OnOpen().
Reference issue
This is the first step towards fixing pion/webrtc#1063.