Table of Contents

Lock / Unlock Room

The EnxRoom.lock() method allows the Moderator to lock the Room which forbids any new user from joining the Session. The Moderator can unlock the Room using EnxRoom.unLock() method to allow subsequent users to join the Session.

Class: EnxRoom

Methods:

  • EnxRoom.lock()
  • EnxRoom.unlock() 

Event Notifications:

  • room-locked – Notification to all the participants in the Room along with the responsible Moderator ID when the room is locked.
  • room-unlocked – Notification to all the participants in the Room along with the responsible Moderator ID when the room is unlocked.
room.lock();

// Participants are notified that room has been locked
room.addEventListener('room-locked', function(event) {             	 
});  

room.unlock();

// Participants are notified that room has been unlocked
room.addEventListener('room-locked', function(event) {              
});

Error Codes / Exceptions

CodeDescription
4101Unauthorized Access. When a user with participant role calls lockRoom() or unlockRoom()
4121Retrying to lock/unlock Room already in the requested state.

Moderate Participants’ entry to a Session

In a knock-enabled Room, a user needs to wait until the Moderator grants them permission to join the Session. The EnxRoom.approveAwaitedUser() method allows the Moderator to approve a user’s entry and EnxRoom.denyAwaitedUser() method is used to decline a user’s entry to the Session.

Methods:

  • EnxRoom.approveAwaitedUser(ClientID, Callback)
  • EnxRoom.denyAwaitedUser(ClientID, Callback)

Event Notifications:

  • user-awaited – Notification to the Moderator when a user awaits their permission to join Room.
  • room-allowed – Notification to the user when the user is permitted to join Room after waiting on a wait-for-moderator or knock-enabled Room.
// Moderator is notified about awaited user
room.addEventListener("user-awaited", function(event, user) {
      // Client Info: user.clientId
      // Create UI for Moderator Interaction to allow or deny 

	// To allow
	room.approveAwaitedUser(clientId, function(success, error) {
	     // Check Success / Error result
	});

	// To deny
	/*
	room.approveAwaitedUser(clientId", function(success, error) {
	     // Check Success / Error result
	});
	*/
});

To manage awaited users when moderator joins late

If the Moderator joins after the participant(s) have sent a request to join the Session in a Knock-enabled Room, then the Moderator can get the list of participants awaiting approval using room.awaitedParticipants. You can utilize this attribute to build UI for Moderator controls to handle pending approvals.

// e.g. room.awaitedParticipants

[
	{	"clientId”: "String", 
		"name": "String" 
	}
]

Wait-for-Moderator Rooms

The Wait-For-Moderator Rooms restrict Participants from joining a session till the Moderator has joined the session. This is achieved by enabling settings.wait_for_moderator:true while Creating a Room. Once a Moderator joins, all awaited participants will automatically join the Session. All subsequent participants can join the session directly without having to wait once the Moderator is in the session.

Participants connecting to room do not receive room-connected event till the Moderator has joined the session. They get connected to the room with room.waitRoom:true. This event can be used to send a message or display a waiting lobby for the joining user.

Event Notifications:

  • room-allowed: Notification to the Participant shortly after the Moderator joins the session and they are also directed to the session subsequently.
// Participant are notified that Moderator is in
room.addEventListener("room-allowed", function(event) {
       // Show a message or move him out of Lobby
});