Browser SDK
Build voice, video and chat applications for the browser
v3
Deprecated
options
Promise<Call>
Set the client to be online so it can receive call invites via WebRTC. The call invites can be accepted or rejected as per user input.
Options object
Callback functions for when a call is received. See IncomingCallHandlers.
1// Receive calls using websocket notifications2client.online({3 incomingCallHandlers: {4 all: __incomingCallHandler,5 },6});78// Function to handle the incoming call notification and stores the invite9window.__incomingCallHandler = (notification) => {10 if (11 !window.__invite ||12 window.__invite.details.callID !== notification.invite.details.callID13 ) {14 // Store call invite15 window.__invite = notification.invite;16 }1718 // Trigger UI update here to convey the ringing state19};2021// Function to answer the call22window.answer = async () => {23 // Accept the call invite24 const call = await window.__invite.accept({25 rootElement: document.getElementById("rootElement"),26 });2728 // Trigger UI update here to convey the connected state29};3031// Function to reject the call32window.reject = async () => {33 await window.__invite.reject();3435 // Trigger UI update here to convey the ready state36};