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

Change detach to interface #575

Merged
merged 1 commit into from
Apr 1, 2019
Merged

Change detach to interface #575

merged 1 commit into from
Apr 1, 2019

Conversation

backkem
Copy link
Member

@backkem backkem commented Apr 1, 2019

This is in preparation of a JS/WASM shim.

@coveralls
Copy link

coveralls commented Apr 1, 2019

Pull Request Test Coverage Report for Build 2771

  • 0 of 1 (0.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+71.5%) to 80.539%

Changes Missing Coverage Covered Lines Changed/Added Lines %
datachannel.go 0 1 0.0%
Totals Coverage Status
Change from base Build 2759: 71.5%
Covered Lines: 3166
Relevant Lines: 3931

💛 - Coveralls

This is in preparation of a JS/WASM shim.
@@ -328,7 +328,7 @@ func (d *DataChannel) ensureOpen() error {
// Please reffer to the data-channels-detach example and the
// pions/datachannel documentation for the correct way to handle the
// resulting DataChannel object.
func (d *DataChannel) Detach() (*datachannel.DataChannel, error) {
func (d *DataChannel) Detach() (datachannel.ReadWriteCloser, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm actually not sure what to say about this change. I probably not know enough of the context. The pattern here is to keep a reference to the webrtc.DataChannel for datachannel properties and use the interface only for read/writes? (I'm not doing that in my code right now). For example, I see the data channel has a StreamIdentifier() that AFAICT we are going to loose. I'm not worried about the StreamIdentifier itself, but seems reasonable to me that the datachannel will hold properties we may want to query.

Copy link
Member Author

@backkem backkem Apr 1, 2019

Choose a reason for hiding this comment

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

Good question.
First off, my original intent for adding the Detach API was to get access to the Read/Write way of using the datachannel since it makes more sense in Go than OnMessage among other reasons. I didn't necessarily want to provide the ability to influence the data channel otherwise since hat can potentially mess with pions/webrtc functionality.
Now for my current goal: I built some functionality on top of this Detach API (backkem/go-libp2p-webrtc-direct) and I'd like to be able to target WASM as well for browser support. Therefore, I'd like to make the Detach API work in WASM as well. This change allows me to create a shim around the browser JS OnMessage API that implements the datachannel.ReadWriteCloser and hopefully keep all these implementation details out of the higher level implementation.

Copy link
Member

Choose a reason for hiding this comment

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

ok, I think it makes sense

@backkem backkem merged commit f1c3fb8 into master Apr 1, 2019
@backkem backkem deleted the detach-interface branch April 1, 2019 13:40
@backkem backkem removed the review label Apr 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants