datachannel creation based on settings (true by default)
- Dominant language
- JavaScript
- Stars
- 7.8k
- Forks
- 983
- PR merge metrics
- No merged PRs in 30d
Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I have to patch `simple-peer@9.10.0` for the project I'm working on.
We need to connect to a remote peer which does not support datachannel. To be able to establish the connection, the settings was modified in order to activate or not the datachannel.
Here is the diff that solved my problem:
```diff
diff --git a/node_modules/simple-peer/index.js b/node_modules/simple-peer/index.js
index b715fb6..a69966d 100644
--- a/node_modules/simple-peer/index.js
+++ b/node_modules/simple-peer/index.js
@@ -51,6 +51,7 @@ class Peer extends stream.Duplex {
this.trickle = opts.trickle !== undefined ? opts.trickle : true
this.allowHalfTrickle = opts.allowHalfTrickle !== undefined ? opts.allowHalfTrickle : false
this.iceCompleteTimeout = opts.iceCompleteTimeout || ICECOMPLETE_TIMEOUT
+ this.withDataChannel = opts.withDataChannel !== undefined ? opts.withDataChannel : true
this.destroyed = false
this.destroying = false
@@ -137,13 +138,15 @@ class Peer extends stream.Duplex {
// - onfingerprintfailure
// - onnegotiationneeded
- if (this.initiator || this.channelNegotiated) {
- this._setupData({
- channel: this._pc.createDataChannel(this.channelName, this.channelConfig)
- })
- } else {
- this._pc.ondatachannel = event => {
- this._setupData(event)
+ if (this.withDataChannel) {
+ if (this.initiator || this.channelNegotiated) {
+ this._setupData({
+ channel: this._pc.createDataChannel(this.channelName, this.channelConfig)
+ })
+ } else {
+ this._pc.ondatachannel = event => {
+ this._setupData(event)
+ }
}
}
```
Is there a possibility to integrate this behavior ?
I can create the PR if you agreed.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.