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
const room = await huddleClient.joinRoom({
	roomId: "YOUR_ROOM_ID",
	token: "YOUR_ACCESS_TOKEN"
});

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
const remotePeer = await 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 = await 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
await room.getLobbyPeerMetadata({peerId: string});
  • getMetadata

Function getMetadata gets Metadata of the room.

ParamsTypeDescriptionReturn Type
dataunknowngets Metadata of the roomvoid

Example

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

updateMetadata

Function updateMetadata update Metadata of the room.

DescriptionReturn Type
Update Metadata of the roomvoid

Example

// Usage
await 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
await 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
await 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
await 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
await 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
await 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
await 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
await 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
await 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
const roomId = room.roomId;
 
// Get lobby peers as a Set
const lobbyPeerSet = room.lobbyPeerSet;
 
// Get lobby peers as an array
const lobbyPeerIds = room.lobbyPeerIds;
 
// Get room configuration settings
const 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", () => {
  console.log("You have successfully joined the room.");
  console.log("Room ID:", room.roomId);
});
 
room.on("new-peer-joined", (data) => {
  console.log("A new peer has joined the room:");
  console.log("Peer ID:", data.peerId);
});
 
room.on("room-closed", () => {
  console.log("The room has been closed.");
});
Audio/Video Infrastructure designed for the developers to empower them ship simple yet powerful Audio/Video Apps.
support
company
Copyright © 2024 Graphene 01, Inc. All Rights Reserved.