-
-
Notifications
You must be signed in to change notification settings - Fork 979
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
Create multiple DataChannels #694
base: master
Are you sure you want to change the base?
Conversation
update twin tap disable remote address test which is blocked by mDNS in chrome update twin tap fix race condition with close listener update twintap coveralls add badge to README fix test paths update twintap update twintap update twintap update twintap update twintap fix race condition with close/destroy
…peer into feature/twintap
… Remove duplicate code.
To be completely honest, after working a with WebRTC for so long I no longer think more advanced features need to be added to simple-peer. |
Is there any prior art/example for this? I've tried it and failed. One problem for doing it over a single data channel for me was that I have a lot of binary data I'm sending but also need the occasional short, "quick" message to be sent immediately. But I found that the large binary data was saturating the channel already and it took a long time for this quick message to go out. On the other hand, if multiple channels can be created with the current master, I'd love to know how people did that! |
It depends heavily on your needs. You can simply create multiple native data channels with different names (and use the first one created for renegotiations only). Or since data channels are message-based, you can start each message with one byte indicating which multiplex channel is used, that was you immediately can have up to 256 possible multiplexed channels. If you want to interleave messages from different channels depending on priority that is also relatively straightforward to do. |
I originally felt the same way about multiplexing, but doing it in JS requires a significant amount of CPU resources even if done right. (Something I learned the hard way implementing simultaneous file transfer for FileFire). Multiple datachannels give you all that for free.
This PR just allows you to create multiple DataChannels. Calling it "multiplexing" isn't exactly accurate as it doesn't turn the Peer into a Multiplex stream.
This is always something to consider. I'd hate for feature creep to make simple-peer unapproachable to a beginner. However, the core API is exactly the same and these DataChannels can be ignored completely (I expect most users to do just that). Anyone using simple-peer for an application that uses >1 stream of data or events will truly need this feature. Notable examples of this include chat clients and file transfer - the flagship usecases of WebRTC. If complexity of API is your main concern, would you prefer if advanced features like multistreaming, multiple datachannels, etc were pulled out of the README into "advanced documentation"? I would agree with this. The "simple" part of simple-peer, at least to me, implies the powerful features of WebRTC are simplified - not that "complex" features are cut entirely for the sake of simplicity. Renegotiation, trickle ice and multistreaming are all very complicated but simple-peer turns them into one-liner constructor arguments and method calls - which is what I love about this library. |
I was misled by previous title then, I though it is "multiplexing" not multiple data channels. Makes sense then, I'll try to find time to review. |
OK, my bad for calling it "multiplexing" - I think it was first called that in the initial feature request. It is not. |
hello! any update when this could be merged ? |
I'm also interested in this! I'm thinking in stream video over a data channel, but continue keeping a data channel with JSON messages |
showing interest here. commented on the #19 |
Is this PR dead? Would be nice to have the ability to add additional data channels to a simple-peer WebRTC connection without having to resort to snooping the codebase and meddling with private fields etc. |
Reimplementation of #334. Implements #19
It allows you to use the same
Peer
duplex stream as before by having the peers inherit theDataChannel
object. But it also allows you to do multiplexing easily like this:Open Problems:
https://bugzilla.mozilla.org/show_bug.cgi?id=1513107
Additional Changes:
send
before the channel is open doesn't buffer data? #690Tested on all combinations of these SauceLabs emulators:
iOS 13.4 @ macOS 10.15
Android 10.0 @ Linux
Microsoft Edge 84 @ macOS 10.15
Firefox 79 @ macOS 10.15
Google Chrome 84 @ macOS 10.15
Safari 13 @ macOS 10.15
As well as all combinations of these real browsers:
Brave 1.10.97 @ macOS 10.15.5
Google Chrome 84.0.4147.105 @ macOS 10.15.5
Firefox 79.0 @ macOS 10.15.5
Safari 13.1.1 @ macOS 10.15.5