Room

The room is the place where the actual meeting takes place. It is the place where the user can interact with other peers.

Methods

Join Room

💡

You can generate Access Token using our Server SDK. To generate roomId you can use our Create Room API.

// joining the room
lifecycleScope.launch {
                try {
                    huddleClient.joinRoom(roomId, token)
                } catch (e: Exception) {
                    Toast.makeText(this@HomeActivity, "Failed to join the room: ${e.message}", Toast.LENGTH_LONG).show()
                }
            }

connect

Function connect connects to the room and returns the instance of the room.

DescriptionReturn Type
Connects to the room and returns the instance of the roomroom

Example

// Usage
val room = room.connect();

remotePeerExists

Function remotePeerExists checks if the remote peer exists in the room. Returns null if the peer does not exist.

ParamsTypeDescriptionReturn Type
peerIdstringChecks if the remote peer exists in the roomRemotePeer | null

Example

// Usage
val remotePeer = room.remotePeerExists("PEER_ID");

getRemotePeerById

Function getRemotePeerById returns the Remote Peer if present in room.

ParamsTypeDescriptionReturn Type
peerIdstringReturns the Remote Peer if present in roomRemotePeer

Example

// Usage
const remotePeer = room.getRemotePeerById("PEER_ID");

getLobbyPeerMetadata

Function getLobbyPeerMetadata gets the Metadata of the lobby peer.

ParamsTypeDescriptionReturn Type
peerIdstringGets the Metadata of the lobby peerroom

Example

// Usage
 room.getLobbyPeerMetadata({ peerId: string });
  • getMetadata

Function getMetadata gets Metadata of the room.

ParamsTypeDescriptionReturn Type
dataunknowngets Metadata of the roomvoid

Example

// Usage
 room.getMetadata({ data: unknown });

updateMetadata

Function updateMetadata update Metadata of the room.

DescriptionReturn Type
Update Metadata of the roomvoid

Example

// Usage
 room.updateMetadata({ data: unknown });
  • getRemotePeerById

Function getRemotePeerById returns the Remote Peer if present in room.

ParamsTypeDescriptionReturn Type
peerIdstringReturns the Remote Peer if present in roomvoid

Example

// Usage
 room.getRemotePeerById(peerId:string);

updateRoomControls

Function updateRoomControls update room control booleans - roomLocked, allowProduce, allowConsume, allowSendData.

ParamsTypeDescriptionReturn Type
dataNewRoomControlsupdate room control booleans - roomLocked, allowProduce, allowConsume, allowSendDatavoid

Example

// Usage
 room.updateRoomControls({ data: NewRoomControls });

closeStreamOfLabel

Function closeStreamOfLabel will close a particular stream of remote peers in the room.

ParamsTypeDescriptionReturn Type
lables | peerIds(optional)Label of the stream | PeerIds of the remote peers, if not provided, it will close the stream of all the remote peersclose a particular stream of remote peers in the roomvoid

Example

// Usage
 room.closeStreamOfLabel({labels:,peerIds?:string[]});

muteEveryone

Function muteEveryone will close the audio stream of all the remote peers who dont have admin permissions in the room.

DescriptionReturn Type
Close the audio stream of all the remote peers who dont have admin permissionsvoid

Example

// Usage
 room.muteEveryone();

admitPeer

Function admitPeer admits a Peer to the room who is in the lobby.

ParamsTypeDescriptionReturn Type
peerIdstringAdmit a Peer to the room who is in the lobbyvoid

Example

// Usage
 room.admitPeer(peerId:string);

denyPeer

Function denyPeer denies the peer from joining the room, who is in the lobby.

ParamsTypeDescriptionReturn Type
peerIdstringDenies the peer from joining the room, who is in the lobbyvoid

Example

// Usage
 room.denyPeer(peerId:string);

kickPeer

Function kickPeer kick peer from room with respective peerId

ParamsTypeDescriptionReturn Type
peerIdstringkick peer from room with respective peerIdvoid

Example

// Usage
 room.kickPeer(peerId:string);

close

Function close closes the room with respective reason.

ParamsTypeDescriptionReturn Type
reason ['LEFT' | 'CLOSED' | 'KICKED' | 'DENIED']stringcloses the room with respective reasonvoid

Example

// Usage
 room.close(reason);

Attributes

NameDescriptionType
roomIdRoom Id of the currently joined room.string or null
lobbyPeerSetLobby peers as a Set.Set<string>
lobbyPeerIdsLobby peers as an array.string[]
configRoom configuration settings including permissions and room state.TRoomInfo["config"] (object)
remotePeersRemote peers in the room.Map<string, RemotePeer>
peerIdsPeer IDs of remote peers in the room.string[]

Example

// Get room ID
val roomId = room.roomId;
 
// Get lobby peers as a Set
val lobbyPeerSet = room.lobbyPeerSet;
 
// Get lobby peers as an array
val lobbyPeerIds = room.lobbyPeerIds;
 
// Get room configuration settings
val config = room.config;

Events

Event NameDescriptionReturns
room-joinedInvoked when a user successfully joins a room.None
room-joined-failedInvoked when a user's attempt to join a room fails.{ message: string, status: string }
room-closedInvoked when a room is closed.None
room-leftInvoked when a user leaves a room.None
room-connectingInvoked when a room is in the process of connecting.None
new-peer-joinedInvoked when a new peer joins the room.data (object): Information about the new peer.
lobby-peers-updatedInvoked when the list of lobby peers is updated.peerIds (array): An array of lobby peer IDs.
peer-leftInvoked when a peer leaves the room.peerId (string): The ID of the peer who left.
room-controls-updatedInvoked when the room's control settings are updated.data (object): Information about the updated control settings.
room-role-updatedInvoked when any remote peer's role is updated.data (object): Information about the updated role.
room-awaitingInvoked when a user is awaiting to join the room.data (object): Reason and message for peer awaiting to join room.
stream-addedInvoked when a new remote peer's stream is added to the room.data (object): Information about the new stream.
stream-closedInvoked when a remote peer's stream is closed.data (object): Information about the closed stream.

Example

// Event listeners for the Room events
room.on("room-joined", () => {
  print("You have successfully joined the room.");
  print("Room ID:", room.roomId);
});
 
room.on("new-peer-joined", (data) => {
  print("A new peer has joined the room:");
  print("Peer ID:", data.peerId);
});
 
room.on("room-closed", () => {
  print("The room has been closed.");
});
Audio/Video Infrastructure designed for developers to empower them to ship simple yet powerful Audio/Video Apps.
support
company
Copyright © 2024 Graphene 01, Inc. All Rights Reserved.