mafintosh / webrtc-swarm

Create a swarm of p2p connections using webrtc and a signalhub
MIT License
380 stars 60 forks source link

possible to pass config options to constructed RTCDataChannels? #16

Closed mreinstein closed 7 years ago

mreinstein commented 7 years ago

in simple-peer (the underlying webrtc module) it's possible to pass options for the RTCDataChannels that get constructed, like this:

const SimplePeer = require('simple-peer');

const config = {
  trickle: false,
  iceServers: [ { url: 'stun:stun.l.google.com:19302' } ],
  // configure the data channels to behave like UDP for maximum performance
  channelConfig: { reliable: false, maxRetransmits: 0, ordered: false },
  ...
};

let p = new Peer(config);

Is there any way to do this in webrtc-swarm ? the default settings produce RTCDataChannels that are reliable, ordered, and attempt packet retransmission. I need to shut this stuff off to get more UDP like behavior for my real-time game.

thanks for a great module btw! 👍

perguth commented 7 years ago

Nice! Extend opts like here https://github.com/mafintosh/webrtc-swarm/pull/15 and file a pull request.

mreinstein commented 7 years ago

@pguth thanks for the pointer; I'll send a PR shortly.

btw, The README has this blurb:

Valid keys for opts include: wrtc, uid, maxPeers

but looking at the code sample from #15 it seems there are other options that can be passed in (this.config, this.stream, this.offerConstraints, ...) Should these be documented in the README?

mreinstein commented 7 years ago

ok I've answered my own question. It looks like these are options that are passed through directly to the underlying simple-peer instances. I'll tweak the README and send along with my PR.