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

Pre negotiated dataChannel? #1620

Open
jimmywarting opened this issue Apr 25, 2019 · 7 comments
Open

Pre negotiated dataChannel? #1620

jimmywarting opened this issue Apr 25, 2019 · 7 comments
Labels

Comments

@jimmywarting
Copy link
Contributor

@jimmywarting jimmywarting commented Apr 25, 2019

Would it make it easier if dataChannel where pre negotiated somehow?

pc.createDataChannel(channelName, {
  negotiated: true,
  id: something  
})

Mostly thinking of other torrent client that integrating webrtc, would make it possible to skip the onDatachannel. step.

@stale

This comment has been minimized.

Copy link

@stale stale bot commented Jul 24, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale label Jul 24, 2019
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Jul 27, 2019

@jimmywarting I'm afraid I don't understand what the purpose of this would be. Could you explain a bit more about what use case this suggestion solves?

@stale stale bot removed the stale label Jul 27, 2019
@stale stale bot removed the stale label Jul 27, 2019
@jimmywarting

This comment has been minimized.

Copy link
Contributor Author

@jimmywarting jimmywarting commented Jul 27, 2019

The purpose would be to create a dataChannel initially (out of band) on both sides. with an agreed-upon id. Without having to worry about state, what side you’re on, or what condition the connection is in.

  • Dose removing the need of having to wait for the other person to send a dataChannel. and be able to skip the hole pc.ondatachannel setup
  • You wouldn't have to care so much if you are a initiator or not.
  • you can configure the datachannel.onmessage earlier
  • you would then use the same codebase more or less
  • you don't have to listen so much to the any of the RTCPeerConnection events.

i know simple-peer takes care of lots of logic for you. but not every torrent client is going to use simple-peer

@no-response no-response bot removed the need more info label Jul 27, 2019
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Jul 27, 2019

Interesting. What are the reasons one would want to use an agreed-upon id? When a peer connects to you, you don't really know anything about them.

@jimmywarting

This comment has been minimized.

Copy link
Contributor Author

@jimmywarting jimmywarting commented Jul 27, 2019

Interesting. What are the reasons one would want to use an agreed-upon id? When a peer connects to you, you don't really know anything about them.

the agreed-upon id could be based of on the peerID who starts or something else

the difference would be that you could have a datachannel right away where as it's now you would have to wait for some extra callback to wait for some dataChannel and setup things afterwards.

To demonstrate with an simple example, peer2 (not the initiator) would have to wait until he receives a dataChannel, you would need a bit more callbacks here and there before you can start playing with it or adding him to some list of connected peers

var pc = new RTCPeerConnection();
if (initiator) {
  setupData({ channel: pc.createDataChannel('testchannel') })
} else {
  pc.ondatachannel = setupData
}

function setup({ channel }) {
  channel.onmessage = startAcceptingMessages
}

with this example both peer1 and peer2 can start to fiddle with the datachannel right away

var pc = new RTCPeerConnection();
var dc = pc.createDataChannel('testchannel', {
  negotiated: true,
  id: from_peer_id_who_started()
})

dc.onmessage = startAcceptingMessages
@feross

This comment has been minimized.

Copy link
Member

@feross feross commented Aug 3, 2019

If you're the initiator, then I see how you might know the peer ID of the peer you are connecting to. In that case, as the initiator you can just create the data channel and start using it. But does the non-initiating peer actually know the peer ID of the remote peer?

@feross feross added the meta label Aug 3, 2019
@jimmywarting

This comment has been minimized.

Copy link
Contributor Author

@jimmywarting jimmywarting commented Aug 4, 2019

But does the non-initiating peer actually know the peer ID of the remote peer?

I think so...? dose not the tracker sends the peer_id of who sent the initial offer to the non-initiator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.