Advance Features Web Toolkit covers API capabilities to build feature-rich End-Point Applications. as Moderator Controls.

Table of Contents

Switch Source Media Devices of Published Stream

A user may want to switch to a different camera or microphone for his published stream. EnableX API allows source switching of devices of a published steam on the fly without the need to unpublish current stream first.

The API allows you to switch the camera and microphone independently or simultaneously. These APIs require ID of the new devices prior to switching. You can use EnxRtc.getDevices() method to fetch a list of available camera and microphones and create a UI for new device selection

Simultaneous Switching Camera & Microphone Source of Published Stream

If user looks to switch both Camera and Microphone used to create published Stream to alternate devices, use EnxRtc.switchMediaDevice() method.

Method: EnxRtc.switchMediaDevice(LocalStream, micDeviceId, camDeviceId, Callback)

Parameters:

  • LocalStream : Published Stream
  • micDeviceId : DeviceId of New Microphone
  • camDeviceId : DeviceId of New Camera
  • Callback : Returns the Updated Stream with new Devices
EnxRtc.switchMediaDevice(localStream, micDeviceId, camDeviceId, function(Stream) {
         if(stream && stream.getID) {
             localStream = stream; // LocalStream updated   
         }
         else {
             // Failed to switch
         }
 });

Switching Camera Source of Published Stream

If user looks to switch Camera used to create published Stream to an alternate Camera, use EnxStream.switchCamera() method.

Method: EnxStream.switchCamera(localStream, camDeviceId, Callback)

Parameters:

  • LocalStream : Published Stream
  • camDeviceId : DeviceId of New Camera
  • Callback : Returns the Updated Stream with new Camera
 localStream.switchCamera(localStream, camDeviceId, function(Stream) {
         if(stream && stream.getID) {
             localStream = stream; // LocalStream updated   
         }
         else {
             // Failed to switch
         }
 });

Switching Microphone Source of Published Stream

If user looks to switch Micrcophone used to create published Stream to an alternate Microphone, use EnxStream.switchMicrophone() method.

Method: EnxStream.switchCamera(localStream, micDeviceId, Callback)

Parameters:

  • localStream : Published Stream
  • micDeviceId : DeviceId of New Microphone
  • Callback : Returns the Updated Stream with new Devices
localStream.switchMicrophone(localStream, micDeviceId, function(Stream) {
         if(stream && stream.getID) {
             localStream = stream; // LocalStream updated   
         }
         else {
             // Failed to switch
         }
 });

Configure and Update Stream Attributes

EnableX API supports the configuration of stream attributes on the fly without interrupting flow of stream:

Configure Stream

If you like to re-configure your stream by adding new or udpating existing specification parameters of a stream. Please use EnxStream.updateConfiguration() method to update the parameters of a stream. Both remote and local streams can use this method of updating the stream parameters.

Method: EnxStream.updateConfiguration(ConfigSpecs, Callback)

Parameters: ConfigSpecs – JSON Specs Object

 // Define Config Specs for Local Stream
var ConfigSpecs = {
     "maxVideoBW": 400, 
     "maxAudioBW": "400" 
 }; 

localstream.updateConfiguration( ConfigSpecs, function(result) {
});

Update Stream Attributes

Use EnxStream.setAttributes() method to update your local stream’s attributes object by adding new attributes or changing existing attributes. Note that you can use custom-attribute names for your stream. Any changes done on stream attributes are propagated to the subscribers of the stream with an event named stream-attributes-updated.

This method works only on local stream.

Method: EnxStream.setAttributes(Attributes) – Local Stream

Parameter: Attributes in JSON with any custom key and value.

Event Notification: stream-attributes-updated – to all subscribers

// Define attributes
var Attributes = {
     "name": "Stream Name", 
     "age": "21",
     "employee_id": "XXX",
     "custom_key": "XXX"
 };

LocalStream.setAttributes(Attributes); // Update

room.addEventListener("stream-attributes-updated", function(evt) {
     // evt.attributes - updated attributes of stream
 }); 

Take Image Snapshot from Video Stream

To take snapshot of a video stream in your application use the EnxStream.getVideoFrameImage() method. The image from the video stream will be captured as raw bitmap data into the Canvas DOM Element.

Method: EnxStream.getVideoFrameImage()

Parameter: None

var myBitmap;
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');

canvas.id = "myCanvas";
document.body.appendChild(canvas);
myBitmap = stream.getVideoFrameImage();

canvas.width = myBitmap.width;
canvas.height = myBitmap.height;
context.putImageData(myBitmap, 0, 0);

Mute / Unmute Audio in a Stream

Use EnxStream.muteAudio() and EnxStream.unmuteAudio() methods to mute and unmute audio from a stream respectively. When a user mutes or unmutes audio from own Published Stream, all other connected users of the room are notified with user-audio-muted and user-audio-unmuted events respectively. Listen to these events to update related UI elements.

Methods:

  • EnxStream.muteAudio() to mute local stream or subscribed stream
  • EnxStream.unmuteAudio() to unmute local stream or subscribed stream

Event Notifications:

  • user-audio-muted to all
  • user-audio-unmuted to all
localStream.muteAudio( function(res) {   
      // Audio muted. Handle UI here
});
     
localStream.unmuteAudio( function(res) {    
     // Audio unmuted. Handle UI here
});

// Notification to others when a user muted audio
room.addEventListener("user-audio-muted", function (event) {
     // Handle UI here
});

// Notification to others when a user muted audio
room.addEventListener("user-audio-unmuted", function (event) {
     // Handle UI here
});

Mute / Unmute Video in a Stream

Use EnxStream.muteVideo() and EnxStream.unmuteVideo() methods to mute and unmute video from a stream respectively. When a user mutes or unmutes video from own Published Stream, all other connected users of the room are notified with user-video-muted and user-video-unmuted events respectively. Listen to these events to update related UI elements.

Methods:

  • EnxStream.muteVideo(Callback) to mute
  • EnxStream.unmuteVideo(Callback) to unmute

Event Notifications:

  • user-video-muted to all
  • user-video-unmuted to all
localStream.muteVideo( function(res) {   
      // Video muted. Handle UI here
});
     
localStream.unmuteVideo( function(res) {    
     // Video unmuted. Handle UI here
});

// Notification to others when a user muted video
room.addEventListener("user-video-muted", function (event) {
     // Handle UI here
});

// Notification to others when a user muted video
room.addEventListener("user-video-unmuted", function (event) {
     // Handle UI here
});

Send Chat Data

INFO! EnableX Web Toolkit 1.4.2 support an advance version of Public & Private Messaging API. Therefore, you are discouraged to use this Stream based Messaging. It will be deprecated in future version.

You may implement basic text-chat communication using EnableX API. The Text-Data is carried on a separate data track in a published Stream and received by all subscribers of the stream.

  • Notes to send message:
    • You must initiate your stream with data track enabled using the JSON Payload as {data: true}
    • You must publish your stream into the room before you can use the EnxStream.sendData() method.
  • Notes to receive message:
    • You must subscribe to the remote stream
    • Listen to the event active-talker-data-in for any incoming message.

Method: EnxStream.sendData(MessageJSON) – to send out mail

Parameter: MessageJSON object has following keys:

  • sender: Sender Name
  • message: Message Body
  • timestamp: Time Stamp in UTC – when the message was originated

Event Notifications: active-talker-data-in to all participants in the room

var MessageJSON = {   
   "sender": "Your Name",
   "message": "Hello World",
   "timestamp": "date/time of message origin in UTC"
}

stream.sendData(MessageJSON); 

room.addEventListener("active-talker-data-in", function(event) {
     // Message received
     // Event JSON 
     // { message : { from : "", message : "", timestamp : ""}}
 }); 

Important Note! EnableX 1.3.* doesn’t support private messaging. Using this API you may only do Public Chat / Messaging. As chat data is carried with the published stream you may not send chat messages unless your stream is published.

Public, Private & Group Messaging

This is an advance messaging feature between Session participants. You can do following type of messaging in a session among participants:

  • Public Messaging: To send message to all connected users.
  • Private Messaging: To send message to a specific user.
  • Group Messaging: To send message to more than one specified users.

Messaging feature neither require the sender to publish his Stream, nor receivers to subscribe.

Method: EnxRoom.sendMessage(Message, IsBroadcast, RecipientIDs, Callback)

Parameters:

  • Message – String. Text message to be sent.
  • IsBroadcast – Boolean. Use true for Public Broadcast, Use false for Private and Group messaging.
  • RecipientIDs – Array of ClientIDs whom you wish to send Private & Group messages.

Notification Event: message-received – receives event.message, a JSON Structure

event.message – Receivable JSON Sample JSON at Recipient End Point

{
    "type": "message-received",
    "message": {
        "broadcast": false,
        "sender": "SENDER_NAME",
        "senderId": "XX",
        "type": "chat",
        "message": "TEXT MESSAGE",
        "timestamp": 99999,
        "receipients": [
            "XOXO", "XOXOXO"
        ]
    }
}

To send & receive message

// To send message to all (Public Messaging)
room.sendMessage("Text Message", true, [], function(data){
    // Message sent
});

// To send to selected Participant (Private Messaging)
room.sendMessage("Text Message", false, ["XXXX"], function(data){
    // Message sent
});

// To receive message notification 
room.addEventListener("message-received", function (event) {
     var InMsg = event.message;
     if (InMsg.broadcast === true) {
         // Handle Public Message
     }
     else {
         // Handle Message from InMsg.sender
     }
 });

File Sharing

Availability: Web Toolkit v1.5.3+

EnableX File Share API allows users of a RTC session to send and receive file(s) to/from each other. Using the available APIs, you can initiate file transfer to share, cancel a file transfer, get notified on a shared file and receive/download shared file.

Upload File to share

The file sharing process starts with a user initiating a file transfer to EnableX Server. To initiate a file transfer use EnxRoom.sendFiles() method.

Method: EnxRoom.sendFiles(files, options, callback)

Parameters:

  • files – FileList. An array of File Type Objects, must be a FileList type. An object of this type is returned by the files property of the HTML <input> element; this lets you access the list of files selected with the <input type="file"> element. For further reference check this.
  • options – JSON Object. This to define file sharing process, scope of file transfer etc. Following keys may be used:
    • isMobile – Boolean. Default false. Set it to true for developing Web View based Mobile Apps.
    • broadcast – Boolean. Default true. This is to share file among all participants in the Session. If you need to target the file share to specific user, then set it to false.
    • clientList – Array of Client IDs. This is to share the file among specified Clients only. If broadcast is set to true, clientList is ignored.
  • callback – Callback method is used to receive status response of sendFiles() method.

Event Listener: fs-upload-result – To have a greater control over the file upload process and get notified at different stages of the process, sender may need to listen to this event. Sender is notified when a file upload starts, gets completed or fails.

var shareOptions = {
	"isMobile": false,
	"broadcast": true
};

var clientList = [];

room.sendFiles(FileList,  shareOptions, clientList, functions(resp) {
	if (resp.result == "0") { // Success JSON Example given below
		
	} else {	// Error JSON Example given below
	
	}
});


room.addEventListener('fs-upload-result', function (event) {
	var msg = event.message;
	switch (msg.messageType) {
		case 'upload-started':
			// Note msg.upJobId for management
			// upload-started event JSON Example given below
			break;
		case 'upload-completed':
			// Know msg.upJobId is completed
			// upload-completed event JSON Example given belowbreak;
			break;
		case 'upload-failed':
			// Know msg.upJobId has failed 
			// upload-failed event JSON Example given belowbreak;
			break;
		default:
			break;
	}

});

Example: Success JSON on sendFiles() Callback

{
	messageType: 'upload-completed', 
	result: 0,
	description: 'upload completed',
	response: {
		uploadStatus: 'completed',
		upJobId: 1,	// #ID of the File Upload Job
		uploadInfo: {	// SDK May provide additional information 
			upJobId: 1,
			name: 'xyz.txt',
			size: 100,	// in bytes
			type: text,	// type of the file
		}	 
	}
}

Example: Error JSON on sendFiles() Callback

{
	"result": 1185,		// A non zero error code
	"error": "file upload failed ", // error
	"desc": "file upload failed because file list is empty"  
}

Example: Event fs-upload-result – JSON upload-started status

{
	messageType: "upload-started",  
	result: 0, 
	description: "upload started",  
	response: {
		uploadStatus: "started",
		upJobId: 1,
		uploadInfo: {
			upJobId: 1
			name: "ks (9).txt"
			size: 168
			type: "text/plain"
		}
	}
}

Example: Event fs-upload-result – JSON upload-completed status

{
	messageType: "upload-completed",  
	result: 0, 
	description: "upload completed",  
	response: {
		uploadStatus: "completed",
		upJobId: 1,
		uploadInfo: {
			upJobId: 1
			name: "ks (9).txt"
			size: 168
			type: "text/plain"
		}
	}
}

Example: Event fs-upload-result – JSON upload-failed status

{
	messageType: "upload-failed",  
	result: 1185, 
	description: "upload failed",  
	response: {
		uploadStatus: "failed",
		upJobId: 1,
		uploadInfo: {
			upJobId: 1
			name: "ks (9).txt"
		}
	}
}

Download shared File

Intended Recipients needs to download each file shared with them individually. Therefore, recipient needs to know information on the available files to download to initiate a download process.

Know files to download

Room Lookup: To know what all files are available for download, you may look into roomObject.availableFiles, its an Array of JSON object carrying file information. e.g.

let myFiles = room.availableFiles;

// myFile contains array of File Information
[
	{
		name: "DP1.pdf",  
		size: 191002,
		index: 0 // ID or File Reference
	} 
]

When New File is availble: A receiver end point is notified as and when a file is made available for download using event listner fs-download-result with event.message.messageType='download-available'

room.addEventListener('fs-download-result', function (event) {
	var msg = event.message;
	switch (msg.messageType) {
		case 'download-available':
			// Look for JSON Object for file infomration
			break;
		 
	}

});

Initiate File Download

As you know about the file(s) to download, you need to initiate download individually using EnxRoom.recvFiles() method.

Method: EnxRoom.recvFiles(index, options, callback) – to initiate download.

Parameters:

  • index– Index or ID of the file to download.
  • options – JSON Object. This to define file download process. Following keys may be used:
    • isMobile – Boolean. Default false. Set it to true for developing Web View based Mobile Apps.
  • callback – Callback method is used to receive status response of recvFiles() method.

Event Listener: fs-download-result – To have a greater control over the file download process and get notified at different stages of the process, receiver may need to listen to this event. Receiver is notified when a file download starts, gets completed or fails.

let myFiles = room.availableFiles;

room.recvFiles(myFiles[0].index, {}, function(resp){
	if (resp.result == "0") { // Success JSON Example given below
		
	} else {	// Error JSON Example given below
	
	}	
});


room.addEventListener('fs-download-result', function (event) {
	var msg = event.message;
	switch (msg.messageType) {
		case 'download-started':
			// Note msg.jobId for cancellation
			// download-started event JSON Example given below
			break;
		case 'download-completed':
			// Know msg.jobId is completed
			// download-completed event JSON Example given belowbreak;
			break;
		case 'download-failed':
			// Know msg.jobId has failed 
			// download-failed event JSON Example given belowbreak;
			break;
		default:
			break;
	}

});

Example: Success JSON on recvFiles() Callback

{
	messageType: 'download-success',
	result: 0, // Succes
	description: 'download-success',
	response: {	// SDK May provide additional information 
		downloadStatus: 'success',
		name: xyz.txt,
		type: text,
		size: 100 // in bytes
	}  
}

Example: Error JSON on recvFiles() Callback

{
	"result": 1180, // A Non-Zero error code
	"error": "room is disconected",
	"desc": "File sharing is not allowed on disconnected rooms"
}

Example: Event fs-download-result – JSON download-started status

{
	messageType: "download-started",  
	result: 0, // Success 
	description: "download-started", 
	response: {
		downloadStatus: "started",
		jobId: "0", // Job ID for downloads in progress
		downloadInfo: {	// SDK May provide additional information 
			name: "ks (4).txt", 
			size: 168, // In bytes
			index: 0,
		}  
	}
}

Example: Event fs-download-result – JSON download-completed status

{
	messageType: "download-completed",  
	result: 0, // Success 
	description: "download-completed", 
	response: {
		downloadStatus: "completed",
		jobId: "0", // Job ID for completed download
		downloadInfo: {	// SDK May provide additional information 
			name: "ks (4).txt", 
			size: 168, // In bytes
			index: 0
		}  
	}
}

Example: Event fs-download-result – JSON download-failed status

{
	messageType: "download-failed",  
	result: 0, // failed 
	description: "download-failed", 
	response: {
		downloadStatus: "failed",
		jobId: "0", // Job ID for completed download
		downloadInfo: {	// SDK May provide additional information 
			name: "ks (4).txt", 
			size: 168, // In bytes
			index: 0
		}  
	}
}

Cancel File Upload

To cancel uploading process of individual files or cancel all files being uploaded, you may use EnxRoom.cancelUploads().

Method: EnxRoom.cancelUploads(id, cancelAll, callback)

Parameters:

  • idupJobId of the file being uploaded. This upJobId is received from sendFiles() method.
  • cancelAll– Boolean. Default false. Set to true to cancel all files being uploaded.
  • callback – Callback method is used to receive status of cancellation request.
room.cancelUploads(id, false, function(resp) {
	// Handle response here
});

Cancel File Download

To cancel downloading process of individual files or cancel all files being downloaded, you may use EnxRoom.cancelDownloads().

Method: EnxRoom.cancelDownloads(id, cancelAll, callback)

Parameters:

  • idjobId of the file being downloaded. This jobId is received from recvFiles() method.
  • cancelAll– Boolean. Default false. Set to true to cancel all files being downloaded.
  • callback – Callback method is used to receive status of cancellation request.
room.cancelDownloads(id, false, function(resp) {
	// Handle response here
});

Share Screen

A Client End Point can start a Screen-Share using EnxRoom.startScreenShare() method. The method will prompt a user to select whether to share the entire desktop or a specific application and creates a stream @ 6fps to publish to the Room. EnxRoom.stopScreenShare() method stops the ongoing Screen Share.

When a user starts or stops Screen Share, all connected users of the room are notified with share-started and share-stopped events respectively.  You need to listen to these events to update UI. As Screen-Share is also a stream which you can play in a Video Player

Methods

  • EnxRoom.startScreenShare(Callback) to start share
  • EnxRoom.stopScreenShare(SharedStream, Callback) to stop given share
  • EnxRoom.unpublish(SharedStream, Callback) alternate way to stop share

Event Notifications:

  • share-started to all
  • share-stopped to all
// Start Screen Share
streamShare = room.startScreenShare( function(result){ 
});

// Stop the Shared Screen
room.stopScreenShare( streamShare, function(result) {
});

// Stop the Shared Screen - Alternate way
room.unpublish( streamShare, function(result, error) {      
     if (result === undefined) {          
         // Failed       
     } else {
          // Share Stopped
     }  
}); 
 
// Notification to all when share starts
room.addEventListener("share-started", function (event) {
     // Get Stream# 11 which carries Screen Share 
     var shared_stream = room.remoteStreams.get(11);  
     shared_stream.play("div_id", playerOptions); // Play in Player
});

// Notification to all when share stops
room.addEventListener("share-stopped", function (event) {
     // Handle UI here
});

Note:

  • This feature is not an Application Share, but a Screen Share. User should select Screen and not any specific App when prompted by browser. App Share experience may differ from browser to browser.
  • Google Chrome versions below 72 needs an Extension to be installed from Web Store to initiate Screen Share i.e. at the Publisher Side.
  • Google Chrome 72 and above browsers don’t require any extension to share screen. They handle Screen Share natively.
  • Firefox doesn’t require any Extension, it handles Screen Share natively.

Use Canvas Streaming

Your application may require to use HTML5 Canvas Object to create stream and publish like a Whiteboard.

Start Canvas Streaming

You can use EnxRoom.startCanvas() method to start canvas streaming with desired streaming option as JSON Parameter.

Important Notes!

  • You need to enable a Room to use Canvas Streaming in it. To enable Canvas Streaming, use { settings: { canvas: true; }} in the JSON Payload to create Room.
  • Once Canvas Streaming gets started, all participants are notified with event canvas-started.
  • Canvas Stream is carried on Stream ID# 21. Client End Point must subscribe to this Stream ID to receive and play it locally.

Method: EnxRoom.startCanvas(CanvasOpt, Callback)

JSON Payload Keys: CanvasOpt JSON may have following keys:

  • canvasSelector: The Canvas DOM Element ID to act as Stream Source
  • fps: Streaming Frame Rate. In number. Range: 1-23

Notification Event: canvas-started – to all participants

var CanvasOpt  = {
     "canvasSelector": "CanvasElementID", 
     "fps": 23
};

room.startCanvas(CanvasOpt, function(arg) {
     if(arg.result == 0) { // Success     
     }
     else { // Error arg.result == 1154 (Frame rate not supported)
     }
});

// Participant receives notification, finds stream ID 21 and plays
room.addEventListener("canvas-started", function (event) {
        var canvasStream = room.remoteStreams.get(21);
        if(canvasStream.stream !== undefined) {
             canvasStream.play("PlayerDiv");
        }
 });

Stop Canvas Streaming

An ongoing canvas streaming may be stopped using API Call below. When streaming is stopped, all participants in the room are notified using an event.

Method: EnxRoom.stopCanvas(Callback)

Event Notification: canvas-stopped – to all participants

room.stopCanvas(CanvasOpt, function(arg) {
     if(arg.result == 0) { // Success     
     }
     else { // Error 
     }
});

// Participant receives notification 
room.addEventListener("canvas-stopped", function (event) {
        // Handle UI. Remove Player of Stream ID# 21
});

Opt to receive desired Video Quality

The Client End Point may opt to receive the desired video quality for available bandwidth. You may create UI based on the enumerated values of video quality as explained below.

Method: EnxRoom.setReceiveVideoQuality(QualityOpt, Callback)

JSON Payload Keys: QualityOpt JSON may have following keys:

  • videoQuality: Enumerated Values: Auto, HD, SD, LD. Set it to Auto if you want EnableX to decide optimum quality for you dynamically.
  • streamType: Enumerated Values: talker, canvas
var Quality = {
     "videoQuality": "", 
     "streamType":  "talker"
 };

 room.setReceiveVideoQuality(Quality, function (result) {
         if(result.result == 0) {
            // Success
         }
         else {
            // Faileld - result.message
         }
 });

Use Custom Signaling

Your Application might require to send instructions, data to one or more recipient connected in a Session to deploy new features, business workflow. For example, you wan to create a Polling mechanism among participants. EnableX supports Custom Signaling method through which you can build such utility that requires passing of messages among participants.

Using Custom Signaling Method, you might send message to all or selected participants in a Room. You can define your custom data structure to pass to meet your business requirement.

Method: EnxRoom.sendUserData(MessageOpt, IsBroadcast, RecipientIDs, Callback)

Parameters:

  • MessageOpt – JSON Object containing custom keys. This object is passed to Recipients as is. EnableX doesn’t enforce it’s structure. Be advised to define keys effectively for signaling needs.
  • IsBroadcast – Boolean. Use true for Public Broadcast, Use false for private messaging to one or more recipients.
  • RecipientIDs – Array of ClientIDs whom you wish to send private messages.

Notification Event: user-data-received – receives MessageOpt JSON as event.message.msg

MessageOpt Sample JSON:

// Example: Important Information you can put with custom keys

var MessageOpt = {
    "broadcast": false,                // Flag for Private message
    "sender": "Sender's Name",
    "senderId": "Sender's Client ID",  // room.clientId 
    "message": "Message body",
    "timestamp": "Date Timestamp",     // Message sent at
}

To send & receive Custom Signaling

// To send custom data / signal to all (Public Messaging)
room.sendUserData(MessageOpt, true, [], function(data){
    // Message sent
});

// To send custom data / signal to selected Participant (Private Messaging)
room.sendUserData(MessageOpt, false, [Recipient_ClientIds], function(data){
    // Message sent
});

// To receive  custom data / signal notification 
room.addEventListener("user-data-received", function (event) {
     var InMsg = event.message.msg;
     if (InMsg.broadcast === true) {
         // Handle Public Message
     }
     else {
         // Handle Message from InMsg.sender
     }
 });

Make Outbound PSTN/SIP Call

Availability: v1.5.3+

Being within EnableX Session, you may initiate an Outbound Call to PSTN Number or SIP URI inviting the called participant to join the session on accepting the call.

Method: EnxRoom.makeOutbound(number, cli_number, callback)

Parameters:

  • dialout_number – String. It either a PSTN Number or SIP URI to dial-out
  • cli_number – Calling Line Identification Number to be added as originator of the Call. In case of PSTN Phone Numbers, this will be validated against your purchased number or opted Shared Number. In case if the CLI does not match, the call will fail with an error “CLI mismatch”
  • callback – It returns whether your request to dial-out has been accepted for processing or failed. Failure notifications are given with error codes.

Event Listner: dial-state-events -Status of the Dialout Process is notified as and when received from Gateway. The JSON Response returns following status codes: initiated, calling, connecting, connected, terminated

room.makeOutbound('00999999999', '00999999999', function(resp) {
	// Whether Dial-Out requests accepted. resp JSON example
	/*
	{ 	"result": 0,  
		"msg": "Success"  
	}
	*/  
}); 

room.addEventListener("dial-state-events ", function(evt) {
	// evnt JSON contains status of dial-out process, example
	/*
	{	number: "9999999999",	/* Dialed Phone Number of SIP URI */
		status: "connected", 	/* Status of dialout Process */
		description: "Detailed description"
	} 

	evt.status may be initiated, calling, connecting, 
	connected & terminated
	*/
}); 

Error Codes – Failure Conditions to accept Dial-Out request

Error CodeDescription
1141Dial-Out request is already in progress
1142CLI doesn’t match with configured phone number

Get Live Stream Statistics

For debugging purposes, you can get life statistics of each stream you are playing at any end-point, be it a local stream or subscribed stream. The following information for each stream is displayed using a Overlay over respective player:

  • For Local Streams
    • Transmission Bandwidth
    • Video Resolution
  • For Subscribed Streams
    • Receiving Bandwidth
    • Video Resolution
    • Available Bandwidth for Remote User
    • Packet Loss

Method: EnxRoom.subscribeStreamStatsForClient(Stream, EnableDisable)

Parameters:

  • Stream: The Stream Object for which you need Statistics. Currently implementation suggests you to pass one of your Local Stream Object only, This would enable Statistics for all the Streams currently being played in your Browser. Future implementation might get you Statistics for given Stream only.
  • EnableDisable: Boolean. Use true to enable Statistics display, false to disable.
room.subscribeStreamStatsForClient(localStream, true);  // To enable
room.subscribeStreamStatsForClient(localStream, false); // To disable 

Manage Console Logging

The Web Toolkit writes different type of logs to the browser console to  help in debugging at development phase. EnableX provides two methods to access and control these log entries.

Set Log Level

The IO Operations to write log may be a considerably time consuming task. Therefore, you may need granular control over the type of log the Toolkit writes to browser console to:

  • Get optimum log entries helping debugging or audit process.
  • Ensure faster communication and media flow with EnableX

Method: EnxRtc.Logger.setLogLevel(Level)

Levels: 0-5 – in decreasing order of log detail. Default is 0.

  • 0 = DEBUG
  • 1 = TRACE
  • 2 = INFO
  • 3 = WARNING
  • 4 = ERROR
  • 5 = NONE
EnxRtc.Logger.setLogLevel(3); 
EnxRtc.Logger.setLogLevel(WARNING); // Alternate way

Get Log Dump

Development Process might require Console Log dump to review it separately, either sending it by mail or creating a UI to show log entries. EnableX API helps you get access to Console Logs.

Method: EnxRtc.Logger.setOutputFunction(Callback)

EnxRtc.Logger.setOutputFunction( function(response) {
       // Use response
}); 

Share Log with EnableX to audit

To share console logs with EnableX Tech Team use the available method in Toolkits. The method sends latest 500 lines of console log to EnableX using HTTP Post. You may need to build your own UI around it. Please request for  user’s consent before you post log to EnableX.

Method: EnxRtc.postClientLogs(Token, Callback)

if( confirm("You are posting Browser Console Log to audit.nSure?")) {
      room.postClientLogs(token, function(res) {
           Logger.info(res.message);   
      });
}

Explore Web Toolkit