Custom Event Handlers

Event handlers will enable you to control what goes on in your application during call events (eg. Call failed, in progress, started, or ended).

// set custom event handlers
 voxbone.WebRTC.customEventHandler = eventHandlers;

An example of this is to set a ringback tone to the event ‘progress’. Here are a few event handlers that change the “Status_message”’s text for each event.

// Register callbacks to desired call events
    voxbone.WebRTC.customEventHandler.progress = function(e) {
       document.getElementById("status_message").innerHTML="Calling " + document.getElementById('number').value;
     };
     voxbone.WebRTC.customEventHandler.getUserMediaFailed = function(e) {
       document.getElementById("status_message").innerHTML="<b><font color='red'>Failed to access mic: " + e.data.cause + "</font></b>";
     };
     voxbone.WebRTC.customEventHandler.failed = function(e) {
       document.getElementById("status_message").innerHTML="<b><font color='red'>Failed to connect: " + e.data.cause + "</font></b>";
     };
     voxbone.WebRTC.customEventHandler.accepted = function(e) {
       document.getElementById("status_message").innerHTML="<b><font color='green'>In Call</font></b>";
     };
     voxbone.WebRTC.customEventHandler.ended = function(e) {
       document.getElementById("status_message").innerHTML="<b><font color='red'>Call Ended</font></b>";
     };
     voxbone.WebRTC.customEventHandler.authExpired = function(e) {
       voxbone.WebRTC.basicAuthInit(username, key);
     };