Session Management

The Cordova SDK provides the following methods:

Record a Session

You can record an RTC session as an individual stream and get it transcoded through a post-session service to create a single composite video file that can be retrieved and replayed using any video player. You can configure the room for auto-recording or invoke APIs to start recording when required.

A session can be recorded in the following ways:

Auto-Recording a Session

You can configure a room with { settings: { auto_recording: true }} during Room Creation to automatically start recording the RTC session taking place in the room.

On-Demand Recording

Client API call helps you to start and stop recording. The available methods are accessible to moderator only. So, on the moderator endpoint, you may need to create a UI to use the methods to start or stop recording a session.

Start Recording

The EnxRoom.startRecord() method allows a moderator to start recording a session. On successful initiation of recording the moderator will be notified using onStartRecordingEvent event listener. All other participants will be notified using onRoomRecordingOn event listener.

  • Method: startRecord()
  • Event Listeners:
    • onStartRecordingEvent : Notification to the moderator that recording has started.
    • onRoomRecordingOn : Notification to all the participants that the recording is ON.

Sample Code

// To start Recording
window.EnxRtc.startRecord();
// Add Event Listener: Moderator is acknowledged
window.EnxRtc.addEventListner("onStartRecordingEvent", function(data){
console.log(JSON.stringify(data.data));
});
// Add Event Listener: Others are notified
window.EnxRtc.addEventListner("onRoomRecordingOn", function (data) {
console.log(JSON.stringify(data.data));
});

Note: There is no limit to the number of times a moderator can start recording within a session. Different segment of a session can be recorded separately.

Stop Recording

The window.EnxRtc.stopRecord() method allows a moderator to stop recording a session. On successful stopping of recording the moderator will be notified using onStopRecordingEvent event listeners. All other participants will be notified using onRoomRecordingOff event listener.

  • Method: stopRecord()
  • Event Listeners:
    • onStopRecordingEvent : Notification to the moderator that recording has stopped.
    • onRoomRecordingOff : Notification to all the participants that the recording is OFF.

Sample Code

// To Stop Recording
window.EnxRtc.stopRecord();
// Add Event Listener: Moderator is acknowledged
window.EnxRtc.addEventListner("onStopRecordingEvent", function(data) {
console.log(JSON.stringify(data.data));
});
// Add Event Listener: Others are notified
window.EnxRtc.addEventListner("onRoomRecordingOff", function (data) {
console.log(JSON.stringify(data.data));
});

Notes:

  • There is no limit to the number of times a moderator can stop recording.
  • The moderator can stop recording in a room defined by the automatically recording feature.

How to fetch Recordings?

Play a Recorded File

If you want to play a recorded file directly from the EnableX server, please note that those files are password protected. EnableX implemented HTTP basic authentication to secure recorded file storage.

Therefore, any video player may not use the file paths only to play them from EnableX server. The player must provide access credentials to pass through the authentication process to play the file.

Sample Code

cordova plugin add cordova-plugin-video-player

For the next steps, refer to the following:

Notes:

  • As an alternate way, download the files from the EnableX server to your server and play the files with or without any security measures you may like to deploy.
  • Files are deleted after 72 hours of creation from the EnableX storage. So, playing the files directly from the EnableX server beyond 72 hours is not guaranteed.

Hard Mute or Unmute a Room

Hard Mute a Room

The window.EnxRtc.hardMute() method allows moderators to hard-mute a room where all the participants are muted. A new participant joining a room in a hard-mute state is automatically muted. The right to unmute a hard-muted room lies only with the moderator. Participants can neither unmute a room or their local streams.

All participants of the room are notified with onReceivedMuteRoom listener. The moderator is notified with onMutedRoom event listener.

  • Method: hardMute()
  • Event Listeners:
    • onReceivedMuteRoom : Notification to all the participants on hard-muting room.
    • onMutedRoom : Notification to the moderator that the room is hard-muted.

Sample Code

// To hard-mute Room
window.EnxRtc.hardMute();
// Add Event Listener: Moderator is acknowledged
window.EnxRtc.addEventListner("onHardMuted", function(data) {
console.log(JSON.stringify(data.data));
});
// Add Event Listener: Others are notified
window.EnxRtc.addEventListner("onReceivedHardMute", function (data) {
console.log(JSON.stringify(data.data));
});

Hard Unmute a Room

The window.EnxRtc.hardUnMute() method is used to change the hard-mute state of a room.

All participants receive the notification from the onReceivedUnMuteRoom listener. The moderator receives notifications from the onUnMutedRoom event listener.

  • Method: hardUnMute()
  • Event Listeners:
    • onReceivedUnMuteRoom : Notification to all the participants on hard-unmuting room.
    • onUnMutedRoom : Notification to the moderator that the room is hard-unmuted.

Sample Code

// To hard-unmute Room
window.EnxRtc.hardUnMute();
// Add Event Listener: Moderator is acknowledged
window.EnxRtc.addEventListner("onHardUnMuted", function(data) {
console.log(JSON.stringify(data.data));
});
// Add Event Listener: Others are notified
window.EnxRtc.addEventListner("onReceivedHardUnMute", function (data) {
console.log(JSON.stringify(data.data));
});

Room Entry Restrictions

Lock Room

The window.EnxRtc.lockRoom() method allows moderators to lock a room, which forbids any new user from joining the session.

  • Method: lockRoom()
  • Event Listeners:
    • onAckLockRoom : Acknowledgement to the moderator that the room has been locked.
    • onLockedRoom : Notification to all the participants that the room has been locked

Sample Code

// To lock Room
window.EnxRtc.lockRoom();
// Add Event Listener: Moderator is acknowledged
window.EnxRtc.addEventListner("onAckLockRoom", function(data) {
console.log(JSON.stringify(data.data));
});
// Add Event Listener: Others are notified
window.EnxRtc.addEventListner("onLockedRoom", function (data) {
console.log(JSON.stringify(data.data));
});

Unlock a Room

Moderators can unlock a room using the window.EnxRtc.unLockRoom() method to allow subsequent users to join the session.

  • Method: unLockRoom()
  • Event Listeners:
    • onAckUnLockRoom : Acknowledgement to the moderator that the room has been unlocked.
    • onUnLockedRoom : Notification to all the participants that the room has been unlocked.

Sample Code

// To unlock Room
window.EnxRtc.unLockRoom();
// Add Event Listener: Moderator is acknowledged
window.EnxRtc.addEventListner("onAckUnLockRoom", function(data) {
console.log(JSON.stringify(data.data));
});
// Add Event Listener: Others are notified
window.EnxRtc.addEventListner("onUnLockedRoom", function (data) {
console.log(JSON.stringify(data.data));
});

Switch Participant Roles

The window.EnxRtc.switchUserRole() method allows moderators to promote a participant to act as a moderator in an ongoing session. The newly appointed moderator is provided access to the moderator controls, and the former moderator becomes a participant in the session. If desired, the new moderator can grant the moderator role to another participant in the session.

  • Method: switchUserRole(clientId)
  • Parameter:
    • clientId: String. Client ID of the participant who is designated as a moderator.
  • Event Listeners:
    • onSwitchedUserRole : Acknowledgement to the moderator that he has requested for switching user roles.
    • onUserRoleChanged : Notification to all the participants in the room when a participant is newly appointed as the moderator. The newly appointed moderator is notified with extra information required to moderate the session.

Sample Code

// To enable stats
window.EnxRtc.switchUserRole(clientId);
// Add Event Listener: Moderator is acknowledged
window.EnxRtc.addEventListner("onSwitchedUserRole", function(data) {
console.log(JSON.stringify(data.data));
});
// Add Event Listener: Others are notified
window.EnxRtc.addEventListner("onUserRoleChanged", function (data) {
console.log(JSON.stringify(data.data));
});

Disconnect a User

The window.EnxRtc.dropUser() method allows moderators to disconnect or force-drop one or more participants from a session.

  • Method: dropUser( clientID)
  • Parameters:
    • clientId: Array. Client Ids to be disconnected.
  • Event Listeners:
    • onAckDropUser : Notification to the moderator that user has been disconnected.
    • onRoomDisConnected : Notification to the affected users with the reason of disconnection from the room.

Sample Code

// To disconnect the user from room
Var array = [c1,c2];
window.EnxRtc.dropUser(array);
// Add Event Listener: Moderator is acknowledged
window.EnxRtc.addEventListner("onAckDropUser", function(data) {
console.log(JSON.stringify(data.data));
});
// Add Event Listener: Others are notified
window.EnxRtc.addEventListner("onRoomDisConnected", function (data) {
console.log(JSON.stringify(data.data));
});

Extend a Session

The duration of a room is limited. It is specified in minutes and defined during the room creation. This time is counted as soon as the first user joins the session.

For practical reasons, a session may need to get extended. So, EnableX allows users to extend a session duration at runtime. The extension process is explained below.

  1. An Extension window opens 10 minutes before the specified closure time of a session. All the connected users are notified of this event.
  2. Users can trigger an extension of the session by calling a method. Once triggered, the Extension Window is closed, thus preventing subsequent extension requests.
  3. If the extension is not triggered, the final Extension window opens 5 minutes before the scheduled closure of the session. All the connected users are notified of this event.
  4. The session can be extended by 10 to 30 minutes. The extended period can vary as there is no restriction on the number of times a session is extended.
  5. When a session is extended, the previous steps are repeated.
  • Method: extendConferenceDuration()
  • Event Listeners:
    • onConferenceRemainingDuration : Notification to everyone in the room when an Extension window is open. It carries a JSON to show how many minutes are left before the closure of the scheduled session.
    • onConferencessExtended : Notification to everyone in the room that the session has been extended.

Sample Code

// Add Event Listner: When Extension Window is open
window.EnxRtc.addEventListner("onConferenceRemainingDuration", function(data) {
window.EnxRtc.extendConferenceDuration(); // Extend Session
});
// Add Event Listner: When Session is extended
window.EnxRtc.addEventListner("onConferencessExtended", function (data) {
console.log(JSON.stringify(data.data));
});

Conclude an Ongoing Session

The window.EnxRtc.destroy() method lets moderators conclude an ongoing session.

  • Method: destroy()
  • Event Listeners:
    • onAckDestroy : Notification to all users in the room when a session is destroyed.
    • onRoomDisconnected : Notification to all the users in a room that the session is closed.

Sample Code

// To destroy Room
window.EnxRtc.destroy();
// Add Event Listener: Moderator is acknowledged
window.EnxRtc.addEventListner("onAckDestroy", function(data) {
console.log(JSON.stringify(data.data));
});
// Add Event Listener: Others are notified
window.EnxRtc.addEventListner("onRoomDisConnected", function (data) {
console.log(JSON.stringify(data.data));
});