Class: EnxRoom


A EnxRoom is where the real time communication session takes place.The Enxroom class handles connection of Client End Points with Signaling Server, Local stream publication and Remote stream subscription.

EnableX rooms can be knock enabled. For all knock enabled rooms, the participant only enters the room when approved by the moderator.

The EnxRoom Class is defined as a Sub-Class of EnxRtc Class. Therefore, a typical way to initialize a rooms will be as below:


var room = EnxRtc.EnxRoom( { "token": "JWT_TOKEN_VALUE"});

The room initialization process would require a valid “Token” to be passed. The token needs to be acquired through a Server API Call. For connecting the client endpoint to the Signalling server, explicitly call the connect() method of Room Class as follows:


room.connect();

To monitor the change in state of the room, they have EventDispatcher (see events for further information), for handling RoomEvents and StreamEvents. For example:

  1. Event 'room-connected' points out that the user has been successfully connected to the room.
  2. Event 'room-disconnected' shows that the user has been already disconnected.
  3. Event 'stream-added' indicates that there is a new stream available in the room.
  4. Event 'stream-removed' shows that a previous available stream has been removed from the room.
The following tables covers all Attributes, Methods of the EnxRoom Class and Event Notifications bound to it.

Attributes:



Parameters Description
localStreams List of local streams connected to room.
remoteStreams List of remote streams connected to room.
roomID Room ID.
status Integer. Room connection status, 1=Connecting, 2=Connected, 0=Disconnected
socket Socket ID
awaitedParticipants It is a map of participants in JSON format, who are waiting to join a knock -knock enabled room
userList List of users joined the room

Methods:

Parameters Description
connect() To connect client end point application to designated room
disconnect() To disconnect client end point from the connected room
disconnectUser() To disconnect any connected user from the room
whoami() To know connect user infomration at end-point
publish (stream, options, Callback) To publish local stream into the room
unpublish (stream, callback) To unpublish a published stream from the room
subscribe(stream, DOM player-container, options, callback) To subscribe a remote stream available in the room
unsubscribe(stream, callback) To unsubscribe a subscribed stream
hardMute(callback) Mutes all participants in a room. Only for moderator use.
hardUnmute(callback) Unmutes all participants in a room. Only for moderator use.
startRecord(callback) To start recording session in a room. Only moderator can use.
stopRecord(callback) To stop recording session in a room. Only moderator can use.
requestFloor(callback) Particpants to request floor acess when the room is in Lecture Mode
grantFloor(clientId, callback) Moderator to grant floor access to a Participant in Lecture Mode
denyFloor(clientId, callback) Moderator to deny floor access to a Participant in Lecture Mode
releaseFloor(clientId, callback) Moderator to release floor access from a granted Participant in Lecture Mode
getMaxTalkers(callback) To get max allowed streams in Active Talker.
setTalkerCount(numTalkers, callback) To set total streams a client end point opts to receive in Active Talker.
getTalkerCount(callback) To get total streams a client end point opted to receive in Active Talker.
postClientLogs(token, callback) To post client end point logs to server for analysis / trouble shooting
approveAwaitedUser(client-Id,callback) To approve the request of user,who is waiting to join a knock-knock enabled room
approveAwaitedUser(client-Id,callback) To deny the request of user,who is waiting to join a knock-knock enabled room
startCanvas(Specs, Callback) To start Canvas Streaming from a given Canvas DOM ID and fps.
stopCanvas(Callback) To stop Canvas Streaming.
setReceiveVideoQuality(Option, Callback) To set deisred Video Quality at the receiving end.
startScreenShare(Callback) To start sharing screen.
stopScreenShare(Callback) To stop sharing screen.


Room Events:

Events Listeners Description
room-connected User successfully connected to the room. When client end point is connected to the room
room-disconnected When client end point is disconnected from room
room-failed When client end point failed to connect to room
room-awaited User has been made to wait for moderator to allow him to join a knock-knock enabled room
user-awaited Moderator is notified with this event that a user is waiting to be approved to get into a knock-knock enabled room
stream-added When publishing stream added to the room.It is not working in Active talker mode.
stream-removed When any publishing stream leaves the room or gets disconnected
stream-failed When a stream fails to get added to the room
stream-subscribed When a stream is subscribed
user-connected When a user is connected to a room, all other connected users are notified about the new user. User Information is passed in the event message.
user-disconnected When a user is disconnected from a room, all other connected users are notified about the users’ exit. User Information is passed in the event message.
user-subscribed When a user subscribes a published stream in a room, the publisher of the stream is notified that his stream is subscribed. User Information is passed in the event message.
user-unsubscribed When a user unsubscribes a stream, the publisher of the stream is notified that the subscriber has unsubscribed. User Information is passed in the event message.
room-muted When all participants in the room are muted by any moderator.
room-unmuted When all participants in a room are unmumted by any moderator.
room-record-on When recording is started in the room, (either implicitly or explicitly), all connected users are notified that room is being recorded.
room-record-off When the recording is turned off (either implicitly or explicitly), all connected users are notified that recording has been stopped in the room.
floor-requested A Moderator listens to this event to know if a Participant has requsted floor access in a Lecture Mode session.
floor-granted A participant listens to this to know when he is granted floor access when requested in a Lecture mode room .
release-floor A Participant listens to this event to know that the Moderator instructed to release floor access in a Lecture Mode session.
floor-released A Moderator listens to this event to know a Participant released floor access in a Lecture Mode session.
floor-denied A Participant listens to this event to know his request to access the floor in a Lecture Mode session has been denied by the Moderator.
active-talkers-updated A Participant listens to this event to get notified about change in active-talker list. Using the updated list, stream display needs to be updated.
bandwidth-updated This Event is sent to Client when there is a significant change in the available downstream (subscribers) bandwidth. Please see the document “How to Handle Bandwidth Management”
screen-share-started A Participant listens to this event to know about a screen shared started by a user when Active Talker is on.
screen-share-stopped A Participant listens to this event to know about a screen stopped by a user when Active Talker is on.
canvas-started A notification event when a canvas stream has started
canvas-stopped A notification event when a canvas stream has stopped



Connect to a Room

Method: EnxRoom.connect()

This method connects a Client End point to the Room. It is used to create a handle to the room object by passing the token that users have previously received from the application server. The token is retreived using the Server API, because it is a user access token. This is an asynchronous method; therefore, we need to add some event listeners to get notified when the Room gets connected or if it failed to connect.

Parameter: None. but requires the JWT Token used in Room Initialization.
Returns: Nothing
Event Listeners: room-connected, room-failed, room-awaited, user-connected, user-awaited, active-talkers-updated

Restrictions: "room-awaited" and "user-awaited" are the events for Knock-Knock enabled room only.
Warnings:
  1. Prior to calling any method, we must initialize the Room with a valid token.
  2. Unless a room is connected, you can’t use any other methods on Room.

var room = EnxRtc.EnxRoom({"token": "JWT_TOKEN_VALUE"}); /* Initiates Room */ room.connect(); /* Try Connecting to the Room */ /* Add all Event Listeners to cover all possible scenarios */
/* When you are connected to the room */ /* addEventListener() has two parameters , one is event type eg : "room-connected" and other argument is to recieve json response from EnableX server*/ room.addEventListener("room-connected", function(event) { console.log("Connected to room!"); /* Here event type is "room-connected": and json response for this perticular event from EnableX Server */ });
/* When your attempt to connect to the room failed */ room.addEventListener("room-failed", function(error) { console.log("Failed to connect room!"); });
/*When you are connected to Signalling Server but not to the Room; You are in queue waiting to be allowed by Moderator to get connected to the knock-knock enabled Room */ room.addEventListener("room-awaited", function(event) { console.log("You are awaited to be connected to room!"); /* Event : json response */ });
/* When another user gets connected to the room, you know who joined */ room.addEventListener("user-connected", function(event, user) { console.log("New User is connected to the room"); });
/* When another user gets connected to Signalling Server in a knock-enable Room, if you are a moderator, you are notified about a user waiting in queue to allow or deny entry to room */ room.addEventListener("user-awaited", function(event, user) { console.log("New User is waiting for your permission to get connected to the room"); /* user is a JSON Message: { "clientId": "String" }*/ });
/* When a Participan gets notified about change in active-talker list. Using the updated list, stream display needs to be updated./ room.addEventListener("active-talkers-updated", function(event) { console.log("Active talker list has updated "); /* response is a JSON Message of updated active talker list: { "type": "active-talker", "message": { "activeList": [{ {"streamId":"1","mediatype" : "audiovideo", clientId" : "a334a039-90af-4c5d-93ad-6f71ea20a36a, name":"abc"}, {"streamId":"2","mediatype" : "audio", clientId" : "b334a039-90af-4c5d-93ad-6f71ea20a36b,"name":"abc1"}, {"streamId":"3","mediatype" : "audio", clientId" : "c334a039-90af-4c5d-93ad-6f71ea20a36c,"name":"abc2"}, {"streamId":"4","mediatype" : "audiovideo", clientId" : "d334a039-90af-4c5d-93ad-6f71ea20a36d, "name":"abc3"}, {"streamId":"5","mediatype" : "audiovideo", clientId" : "e334a039-90af-4c5d-93ad-6f71ea20a36e, "name":"abc4"}, {"streamId":"6","mediatype" : "audiovideo", clientId" : "f334a039-90af-4c5d-93ad-6f71ea20a36f, "name":"abc5"} }], "active": true } } */ });
/*A Participant listens this event to know about a screen shared started by a user when Active Talker is on.*/ room.addEventListener("screen-share-started", function(event) { console.log("Screen shared started by a user when Active talker is on"); /* response is a JSON Message {"clientId" : "d334a039-90af-4c5d-93ad-6f71ea20a36e", "name" : "Web", "result" : 0, "streamId" : 11} */ }); /*A Participant listens this event to know about a screen shared stoped by a user when Active Talker is on.*/ room.addEventListener("screen-share-stopped", function(event) { console.log("Screen shared stoped by a user when Active talker is on"); /* response is a JSON Message {"clientId" : "d334a039-90af-4c5d-93ad-6f71ea20a36e", "name" : "Web", "result" : 0, "streamId" : 11} */ });
/* Participant gets notified about change in available subscriber bandwidth. This even returns a JSON message defined as follows:/* room.addEventListener("bandwidth-updated", function(event) { console.log("Active talker list has updated "); /* response is a JSON, where message indicates a stream direction (Upstream for PublisherBw, Downstream for SubscriberBw) and bandwidth indicates available network bandwidth in Bytes { "message": "SubscriberBandWidth", "bandwidth": [ { "streamId": 1, "subscriberBw": 300000, "publisherBw": 328215 }, { "streamId": 2, "subscriberBw": 1505400, "publisherBw": 135229 } ] }*/ });



Disconnect from Room

Method: EnxRoom.disconnect()

This method disconnects Client End point from the Room. This is an asynchronous method; therefore, we need to add an event listener to get notified when its disconnected.
Parameter: None
Returns: Nothing

Event Listeners: room-disconnected


room.disconnect(); /* Add Event Listeners to know when you are disconnected from the room */ room.addEventListener("room-disconnected", function(event) { console.log("Disconnected from the room!"); });



To know Connected User Information at End-Point

Method: EnxRoom.whoami()

This method returns user-meta information about the user connected on a End-Point.
Parameter: None
Returns: user-meta

Event Listeners: room-disconnected


var usermeta = room.whoami(); /* User Meta JSON received */ /* { "clientId": "String", /* Client-ID assigned by Sig Server */ "name": "String", /* Name of the User */ "user_ref": "sdfds", /* User Reference */ "role": "participant", /* User Role */ "permissions": { /* User Permissions */ "publish": true, "subscribe": true, "record": false, "stats": true, "controlhandlers": true } } */



Disconnect connected Users

Method: EnxRoom.disconnectUser(ClientId, Callback)

This is a Moderator Control. Using this API Call, a Moderator disconnects a Connected User from the Room.


Parameter:
  • ClientId: ClientId of connected user to be disconnected

Returns: Nothing

Event Listeners: user-disconnected


room.disconnectUser(ClientId); room.addEventListener("user-disconnected", function(event) { console.log("Disconnected from the room!"); /* Event : json details */ });



Publish Stream into Room

Method: EnxRoom.publish(Stream-Object, Publishing-Options, Callback)

This method publishes a locally initiated stream into the connected room. As the stream is added to the Room, all other connected users are notified with an event stream-added, so that they may subscribe the stream.


Parameter:
  • • Stream-Object: Initiated local stream Object
  • • Publishing-Options: JSON
    {
    	"minVideoBW":"Number", /* Min Bandwidth required to subscribe Video Stream */
    	"maxVideoBW": "Number" /* Max Bandwidth required to subscribe Video Stream */
    	"scheme": "notify-break-recover" /* Use this constant always */
    }
  • • Callback: User defined callback functions

Returns: Nothing

Event Listeners: stream-added, stream-failed


room.publish(localStreamObject, PublishOptions, Callback); /* When the stream is published into the Room */ room.addEventListener("stream-added", function(event) { if (localStreamObject.getID() === event.stream.getID()) { console.log("Stream Published!"); } }); /* When the Stream publishing failed */ room.addEventListener("stream-failed", function(event) { console.log("Failed to publish Stream!"); });



Unpublish Stream from Room

Method: EnxRoom.unpublish(Stream-Object, Callback)

This method unpublishes a published local stream from the Room. As the stream gets unpublished, all other connected users are notified with an event stream-removed.


Parameter:
  • • Stream-Object: Published local stream Object
  • • Callback: User defined callback function with two parameters, result and error. It returns result=true if stream is successfully unpublished.
Returns: Nothing
Event Listeners: stream-removed

room.unpublish(localStream, function(result, error){ if (result === undefined){ console.log("Failed to unpublish: ", error); } else { console.log("Unpublished the Stream!"); } }); /* When the stream is unpublished from the Room, every connected user is notified */ room.addEventListener("stream-removed", function(event) { if (localStreamObject.getID() === event.stream.getID()) { console.log("Local Stream unpublished!"); } });



Subscribe a Remote Stream in Room

Method: EnxRoom.subscribe(Stream-Object, Remote-Stream-Options, Callback)

This method is used to subscribe to a Stream available in the Room. To subscribe any stream, you need to know the available stream/streams first. Remote streams available can be found in the following ways:

  1. room-connected event: As you get connected to the room, this event brings in a room-meta-info JSON which includes all streams available in the room.
  2. stream-added event: As new stream gets published into the room, you are notified with this event that contains a stream-meta-info JSON about the joined stream.

Parameter:
  • • Stream-Object: Remote Stream Object which we want to subscribe
  • • Remote-Stream-Options: Options to subscribe to specific tracks of the stream. JSON
    	{ 
    		"audio": true,	/* Subscribe to Audio */
    		"video": false,	/* Subscribe to Video */
    		"data": true		/* Subscribe to Data (File Transfer / Text Chat) */
    	}
    
  • • Callback: User defined callback function with two parameters, result and error. It returns result=true if stream is successfully subscribed.
Returns: Nothing
Event Listeners: stream-subscribed, user-subscribed

Note: You are free to subscribe to your own local stream, but that would a delayed stream as it hops from you to media server and back. Also, you will experience echoed audio.


room.subscribe(remoteStreamObj, {audio: true, video: false}, function(result, error){ if (result === undefined){ console.log("Failed to subscribe stream", error); } else { console.log("Stream subscribed!"); } }); /* When the stream is subscribed */ room.addEventListener("stream-subscribed", function(event) { console.log("Stream subscribed"); /* Event : json details */ }); /* When your local stream is subscribed by others*/ room.addEventListener("user-subscribed", function(event) { console.log("User subscribed to your stream"); /* event contains JSON {"stream": {StreamObj},"user": “user-meta-info”} */ });



Unsubscribe a subscribed Remote Stream

Method: EnxRoom.unsubscribe(Stream-Object, Callback)

This method unsubscribes a Remote Stream which you had subscribed earlier. After the stream is unsubscribed, the HTML DOM Element playing the Stream will become empty.


Parameter:
  • • Stream-Object: Remote Stream Object which we want to unsubscribe
  • • Callback: User defined callback function with two parameters, result and error. It returns result=true if stream is successfully unsubscribed.

Returns: Nothing

Event Listeners: stream-unsubscribed, user-unsubscribed

Note: You are free to subscribe to your own local stream, but that would a delayed stream as it hops from you to media server and back. Also, you will experience echoed audio.


room.unsubscribe(remoteStreamObj, function(result, error){ if (result === undefined){ console.log("Failed to unsubscribe stream", error); } else { console.log("Stream unsubscribed!"); } }); /* When the stream is subscribed */ room.addEventListener("stream-unsubscribed", function(event) { console.log("Stream unsubscribed!"); }); /* When your local stream is unsubscribed by others*/ room.addEventListener("user-unsubscribed", function(event) { console.log("User unsubscribed your stream"); /* event contains JSON {"stream": {StreamObj},"user": “user-meta-info”} */ });



Hard mute/unmute a room

Method: room.hardMute(callback) , room.hardUnmute(callback)

This method sends event to every participants present in the room and forcefully mutes them and send a response json as a callback


Parameter:
  • • callback: User defined callback function with a response JSON which has result code to identify success or failure.

Returns: Nothing

Event Listeners: room-muted, room-unmuted


/* Calling hard mute */ room.hardMute(function(result){ if (result != 0){ console.log("Error when muting room",result); } else { console.log("Successfully muted room",result); result = {"result": "0", "msg": "room muted"} ; } }); /* Calling hard unmute */ room.hardUnmute(function(result){ if (result != 0){ console.log("Error when unmuting room", result); } else { console.log("Successfully unmuted room"); /* result = {"result": "0", "msg": "room unmuted"} ;*/ } }); /* When room is muted, all participants are notified */ room.addEventListener("hard-mute-room", function(event) { console.log("Room has been muted"); /* event JSON = {type: "hard-mute-room", streams: "", message: "room hard muted", room: "", users: undefined} */ }); /* When room is unmuted, all participants are notified */ room.addEventListener("hard-unmute-room", function(event) { console.log("Room has been unmuted"); /* event JSON = {type: "hard-unmute-room", streams: "", message: "room hard unmuted", room: "", users: undefined} */ }); /* When room is unmuted, all participants are notified */ room.addEventListener("room-unmuted", function(event) { console.log("Room has been unmuted"); /* event JSON = {type: "hard-unmute-room", streams: "", message: "room hard unmuted", room: "", users: undefined} */ });



Start / Stop Recording of Session

Method: room.startRecord(callback) , room.stopRecord(callback)

These methods are only for Moderator. The startRecord() function is used to start recording of the conference session and stopRecord() to stop recording. You receive a callback to handle success/failure of your requst. On successful, each participant will be notified with events room-record-on and room-record-off respectively.


Parameter:
  • • callback: User defined callback function with a response JSON which has result code to identify success or failure.

Returns: Nothing

Event Listeners: room-record-on, room-record-off


/* Calling startRecord */ room.startRecord(function(result,error){ if (result){ console.log("Room recording is started successfully ", result); /*result = {result: 0} */ } else { console.log("Error in start recording", error); /*error = {error:null}*/ } }); /* Calling stopRecord */ room.stopRecord(function(result,error){ if (result){ console.log("Room recording is stopped successfully", result); } else { console.log("Error in stop recording", error); } }); /* When room is put on record, all participants are notified */ room.addEventListener("room-record-on", function(event) { console.log("This room is being recorded"); /* event JSON = { type: 'room-record-on', message: 'Room recording started'} */ }); /* When room is put off the record, all participants are notified */ room.addEventListener("room-record-off", function(event) { console.log("Room Recording has been stopped"); /* event JSON = { type: 'room-record-off', message: 'Room recording stopped'} */ });



Request Floor Access

Method: EnxRoom.requestFloor(Callback)

This method is available for Participant during Lecture mode of a session. Each participant seeks access to the floor (oppprtuniy to speak from moderator) to publish themseleves, which subsequently is either accepted or denied by the Moderator of the Room. Participant receives callback with JSON Message to confirm the request status.


Parameter:
  • • Callback: User defined callback function with one parameters, response. It returns a JSON message confirming the request status i.e. whether the request has been received at the Moderator end or not.

Returns: Nothing

Event Listeners: floor-requested

Restriction: This method is available to participants in Lecture mode only


room.requestFloor(function(response){ if (response.result == 1701) { console.log("Request has been received by Moderator); } else { console.log(response.message); } /* JSON: response */ /* { "result": "1701", "message": "Floor Request received by Moderator" } { "result": "1702", "message": "Previous Floor Request is pending at Moderator" } */ }); /* Moderator listens for incoming Floor Request */ room.addEventListener("floor-requested", function(event) { console.log("New Floor Request received from ", event.clientId); /* JSON: event */ /* { "clientId": "String", "name": "String" } */ });



Grant Floor Access

Method: EnxRoom.grantFloor(ClientId, Callback)

This method is available for Moderator during Lecture mode of a session. Each Participant requested Floor Control may individually be granted access to the Floor using this API Call. Once granted access, the Participant receives notification with JSON Message and immediately his stream is published into the Room.

Note that the Moderator may grant access to any single requested participant at any given point of time. He can't grant access to subsequent participant until he releases floor access from the particiant with floor access.


Parameter:
  • • ClientId: It’s the Client ID for the participant whom access is being granted.
  • • Callback: User defined callback function with one parameters, response. It returns a JSON message confirming the grant status

Returns: Nothing

Event Listeners: floor-granted

Restriction: This method is available to Moderator in Lecture mode only


room.grantFloor(ClientID, function(response){ console.log(response.result); /* JSON: response */ /* { "result": "code", "message": "String" } */ }); /* Participant listens to know when he is granted floor control */ room.addEventListener("floor-granted", function(event) { console.log("Floor Control granted"); /* JSON: event */ /* { "clientId": "String", "message": "String" } */ });



Deny Floor Request

Method: EnxRoom.denyFloor(ClientId, Callback)

This method is available for Moderator during Lecture mode of a session. Each Participant requesting Floor Control may individually denied access to the Floor using this API Call. Once access request is denied, the Participant receives notification with JSON Message.


Parameter:
  • • ClientId: It’s the Client ID for the participant whose request for floor access is being denied.
  • • Callback: User defined callback function with one parameters, response. It returns a JSON message confirming the request status

Returns: Nothing

Event Listeners: floor-denied

Restriction: This method is available to Moderator in Lecture mode only


room.denyFloor(ClientID, function(response){ console.log(response.result); /* JSON: response */ /* { "result": "0", "message": "Participant has been notified abuot denied access request" } */ }); /* /* Participant listens to know if he is denied floor access */ room.addEventListener("floor-denied", function(event) { console.log("Floor Access Request has been denied"); /* JSON: event */ /* { "clientId": "Code", "message": "String" } */ });



Release Floor Control

Method: EnxRoom.releaseFloor(ClientId, Callback)

This method is available for Moderator during Lecture mode of a session. Moderator instructs a Participant having the Floor Control to immediately release the floor using this Method. Participant listens to the instruction and immediately releases Floor Control.


Parameter:
  • • ClientId: It’s the Client ID for the participant who is to be instructed to release floor control.
  • • Callback: User defined callback function with one parameters, response. It returns a JSON message confirming the release status

Returns: Nothing

Event Listeners: floor-released, release-floor

Restriction: This method is available to Moderator in Lecture mode only


room.releaseFloor(ClientID, function(response){ console.log(response.result); /* JSON: response */ /* { "result": "0", "message": "Floor Release request has been forwarded" } */ }); /* Participant listens to know when he needs to release floor control */ room.addEventListener("release-floor", function(event) { console.log("Floor Access Request has been denied"); /* JSON: event */ /* { "clientId": "String", "message": "String" } */ }); /* Moderator listens to know when the intended participant has released the floor control */ room.addEventListener("floor-released", function(event) { console.log("Floor has been released "); /* JSON: event */ /* { "clientId": "String", "message": "String" } */ });



To get max allowed Active Talkers

Method: EnxRoom.getMaxTalkers(Callback)

This method is available for all users during Active Talker Mode. Using this method, you can get maximum number of allowed Active Talkers in the Callback.


Parameter:
  • • Callback: User defined callback function with one parameters, response. It returns a JSON message with max allowed active talkers.

Restriction: This method is available only when Active Talker is enabled

Returns: Nothing


room.getMaxTalkers(function(response){ console.log(“Max Allowed Talkers:”, response); /* JSON: response */ /* { "result": 0, "maxTalkers": 4 } */ });



To get / set total streams to receive in Active Talker

Method: EnxRoom.setTalkerCount(numTalkers, Callback), EnxRoom.getTalkerCount(Callback)

The setTalkerCount method is used to opt total number of streams to receive at a Client End point in Active Talkers. The getTalkerCount method is used to know opted streams in Active Talker.


Parameter:
  • • numTalkers: Is given in JSON, e.g. { "numTalkers": 2 }; to set total number of streams opted to receive in Active Talker.
  • • Callback: User defined callback function with one parameters, response.

Restriction: This method is available only when Active Talker is enabled

Returns: Nothing


room.setTalkerCount( 2 , function(response){ console.log(response); /* JSON: response */ /* { "result": 0, "numTalkers": 3 } */ }); room.getTalkerCount(function(response){ console.log(response); /* JSON: response */ /* {"result": 0, "maxTalkers": 4 } */ });



Post Client End Point Logs to Server

Method: EnxRoom.postClientLogs(token, Callback)

This method is available for moderator and participants. Using this function, client end point logs are posted to the Server for analysis or trouble shooting. Developers are advised to invoke this method only after a user confirms / opts to post logs.


Parameter:
  • • token: It's the token received from Server.
  • • Callback: User defined callback function with one parameters, response. It returns a JSON message confirming the release status

Returns: Nothing


room.postClientLogs(token, function(response){ console.log(response.result); /* JSON: response on success */ /* { "result": "0", "message": "Log posted successfully" } */ /* JSON: response on error */ /* { "result": "0", "message": "Error in posing log" } */ });



Approve Awaited User

Method: approveAwaitedUser(client-Id,callback)

To approve the request of user, who is waiting to join a knock-knock enabled room


Parameter:
  • • client-Id: User id .
  • • Callback: User defined callback function with two parameters, success and error. It returns a JSON message of success or failure

Returns: JSON message

Restriction: This method is available to Moderator only in a Knock-Knock enabled room


room.approveAwaitedUser("Client-Id", function(success,error){ console.log("JSON response of approval success/failure"); /* JSON: response */ /* { "result": "0", "dese" : "", "message": "" } });



Deny Awaited User

Method: denyAwaitedUser(client-Id,callback)

To deny the request of user,who is waiting to join a knock-knock enabled room


Parameter:
  • • client-Id: User id .
  • • Callback: User defined callback function with two parameters, success and error. It returns a JSON message of success or failure

Returns: JSON message

Restriction: This method is available to Moderator only in a Knock-Knock enabled room


room.denyAwaitedUser("Client-Id", function(success,error){ console.log("JSON response of approval success/failure"); /* JSON: response */ /* { "result": "0", "dese" : "", "message": "" } });



Start Canvas Streaming

Method: EnxRoom.startCanvas()

This method start canvas streaming from a given Canvas Tag DOM Element ID at a desired FPS for capturing the canvas into the stream.


Parameter:
  • • Stream-Object: Specication: Its JSON to specify source of the Canvas Streaming and the desired FTP. e.g. { "canvasSelector": "Canvas Element DOM ID", "fps": 23 /* fps range: 1-23 */ }
  • • Callback: : User defined method to handle JSON response and UI, e.g.
  • { "result": 0, /* Success */ "id": "Stream ID" /* ID of canvas stream */ }

Event Listeners: canvas-started

room.startCanvas({"canvasSelector":"canvasDOMID", "fps": 23}, function(arg){ if(arg.result == 0) { // Success – handle your UI } else { // handle error /* { "result": 1154, "error": "Given frame rate is not supported", "desc": "Frame rate might be negative or not a number which is not accepted by captureStream method" } */ } }); plugin.addEventListener("canvas-started", function (event) { // Canvas Stream to be played });



Stop Canvas Streaming

Method: EnxRoom.stopCanvas()

This method stops any ongoing canvas streaming.


  • Parameter: None, Callback
  • Event Listeners: canvas-stopped
plugin.addEventListener("canvas-stopped", function (event) { // Canvas Stream to be removed from UI }); room.stopCanvas( function(arg) { if(arg.result == 0) { // Success – handle your UI } else { // handle error } }); plugin.addEventListener("canvas-stopped", function (event) { // Handle your UI });



Receive changed Video Stream Quality

Method: EnxRoom.setReceiveVideoQuality(options, callback)

This method is used to receive different video quality. You may opt to “auto” too to let Server handle Video Quality based on your bandwidth.


Parameter:

  • Options: Its JSON to specify Options Video Quality to receive. e.g. { "streamType": "canvas", /* canvas, talker (Active Talker) */ "videoQuality": “HD” /* HD, SD, LD (Low), Auto (Auto Selection by Server based on Bandwidth) */ }
  • Callback: User defined method to handle JSON response and UI, e.g.
room.setReceiveVideoQuality(options, function (arg) { if(arg.result == 0) { // Success – handle your UI } else { // handle error /* { "result": 1155, "error": "Invalid options", "desc": "Invalid options parameters - streamType or videoQuality" } */ } });


Start / Stop Screen Share

To start sharing your desktop, you can call startScreenShare() method. And to stop an screen sharing, call stopScreenShare().


// To start Share streamShare = room.startScreenShare(function(res){ }); // To stop Share room.stopScreenShare(streamShare, function(res){ }); // To stop Share - Alternate way room.unpublish(streamShare);

When a screen share is started, all users are notified with share-shared event. You need to listen to this event and update any UI if needed by you.


room.addEventListener("share-started", function (event) { });

When a screen share is stopped, all users are notified with share-stopped event. You need to listen to this event and update any UI if needed by you.


room.addEventListener("share-stopped", function (event) { });

Note that Chrome can initiate a screen share with an installable Web Plug-in only. The Plug-in available on Chrome Web Store