Fleshing out the Skeletal Signaling Callbacks

We need to call initializePeer() from within two signaling callbacks, handleScConnectedPeer() and handleScConnectedPeers(), that fire in response to peer-connection events. Both callbacks must now process data payloads containing peer IDs from the signaling channel.

Let’s start with handleScConnectedPeer(), which works with a single incoming ID. It should initialize a peer for that ID and establish the call features, too:

 function​ handleScConnectedPeer(id) {
  console.log(​`Newly connected peer ID: ​${id}​`​);
»// be impolite with each newly connecting peer
» initializePeer(id, ​false​);
» establishCallFeatures(id);
 }

You might recall that handleScConnectedPeer()

Get Programming WebRTC now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.