0

I want to make a data channel for the local peer connection and remote peer connection to connect to.

Can I run peerConnection.createDataChannel('datachannel'); on BOTH the local and remote clients so that they both connect to the same data channel? Or does the caller (aka the client running createOffer) have to be the one to run this command and the answerer (aka the client running createAnswer) have to run peerConnection.ondatachannel = ... ?

Just trying to see if I can simplify it or if the caller has to be the one to create the data channel.

bigpotato
  • 26,262
  • 56
  • 178
  • 334
  • Possible duplicate of [How are data channels negotiated between two peers with WebRTC?](http://stackoverflow.com/questions/43788872/how-are-data-channels-negotiated-between-two-peers-with-webrtc) – jib May 12 '17 at 19:42

1 Answers1

1

createOffer() caller should create pc.createDataChannel('datachannel'); and createAnswer() receiver should just listen for pc.ondatachannel

See full explanation and demo

Sasi Varunan
  • 2,806
  • 1
  • 23
  • 34