Creating an answer in the callee's browser
Once you have connected to the web page as a callee, and the caller's browser has initiated the JSEP offer/answer process, you will receive a new_description
signal. We then call peer_connect.setRemoteDescription()
to set this as the remote description, and if this description is really an offer, then we call peer_connection.createAnswer()
to send back a response. Just like in the code snippet for the caller, we use the new_description_created()
function to set this answer as our local description, and then serialize it into a new_description
signal that is then sent back to the caller:
// handle signals as a callee function callee_signal_handler(event) { ... } else if (signal.type === "new_description") { peer_connection.setRemoteDescription( new rtc_session_description(signal.sdp), function () { if (peer_connection.remoteDescription.type == "offer") { peer_connection.createAnswer(new_description_created, log_error...