I have successfully connected clients A and B. Problem is I want to add new clients, C and D to build a group chat. Do I need to spawn new RTC connection and exchange offer/answer/ICE candidates for each clients? For example:
A connects to B A connects to C A connects to D B connects to C B connects to D C connects to D
Each of the above client combination spawns their own RTCPeerConnection and goes through the webrtc handshake (offer,icecandidate,answer)
As many as you like. You can cram anywhere from one to a million users into a WebRTC call.
WebRTC is a peer-peer communication protocol.
Peer connections is the part of the WebRTC specifications that deals with connecting two applications on different computers to communicate using a peer-to-peer protocol. The communication between peers can be video, audio or arbitrary binary data (for clients supporting the RTCDataChannel API).
Do I need to spawn new RTC connection and exchange offer/answer/ICE candidates for each clients?
Exactly. Each client just need to create new RTCPeerConnection
, attach their unique audio and video tracks to them and exchange their SDP & ICE candidates every time a new client arrives.
An example is available here: https://webrtc.github.io/samples/src/content/peerconnection/multiple/
Source code: https://github.com/webrtc/samples/blob/gh-pages/src/content/peerconnection/multiple/js/main.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With