Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upPre negotiated dataChannel? #1620
Comments
This comment has been minimized.
This comment has been minimized.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
This comment has been minimized.
This comment has been minimized.
|
@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? |
This comment has been minimized.
This comment has been minimized.
|
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.
i know simple-peer takes care of lots of logic for you. but not every torrent client is going to use simple-peer |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
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 |
This comment has been minimized.
This comment has been minimized.
|
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? |
This comment has been minimized.
This comment has been minimized.
I think so...? dose not the tracker sends the |
Would it make it easier if dataChannel where pre negotiated somehow?
Mostly thinking of other torrent client that integrating webrtc, would make it possible to skip the onDatachannel. step.