Initiating a call

Now that we have set everything up properly, we are ready to initiate a call with a remote user. Sending the offer to another user starts all this. Once a user gets the offer, he/she will create a response and start trading ICE candidates, until he/she successfully connects. This process is exactly the same as mentioned in Chapter 3, Creating a Basic WebRTC Application, except for the fact that it is now being done remotely over our signaling server. To accomplish this, we add the following code to our script:

callButton.addEventListener("click", function () { var theirUsername = theirUsernameInput.value; if (theirUsername.length > 0) { startPeerConnection(theirUsername); } }); function startPeerConnection(user) { connectedUser ...

Get Learning 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.