June 2024
Beginner to intermediate
268 pages
6h 26m
English
Let’s create a new function to populate the $peers map that you created in Stripping Back Self and Peer. The map will maintain per-peer instances of RTCPeerConnection and the state properties formerly on $self.
At the top of the stack of functions in the Call Features and Reset Functions part of your main.js file, open up a new function definition for initializePeer(). This function should take two parameters: id, for tracking the peer ID value returned by the signaling channel, and polite, for assigning a Boolean to indicate politeness:
| | /** |
| | * Call Features & Reset Functions |
| | */ |
| | |
| | function initializePeer(id, polite) { |
| | $peers.set(id, { |
| | connection: new RTCPeerConnection($self.rtcConfig), ... |
Read now
Unlock full access