Restructuring WebRTC Callbacks with Closures

So far, rewriting the peer-to-peer code to work on multipeer calls has been pretty straightforward. Well, fairly straightforward. Fine—straightforwardish, the way an alien abduction is straightforward. However you want to spin it, your work towards a multipeer WebRTC app has required shifting some logic around on the signaling callbacks and introducing a new id variable to a number of functions.

By contrast, the revisions you’ll make to your WebRTC callbacks require rethinking your approach to callbacks entirely, especially how the callbacks themselves are registered.

Let’s step back and think about peer IDs for a moment: each of your WebRTC callbacks needs to be associated with a specific peer ID’s ...

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.