useLobby

The useLobby hook allows you to interact with peers in the lobby, i.e. who are waiting to join a locked room. As an admin, you can choose to admit these peers into the room or deny them from joining the room.

NameDescriptionReturn TypeParams
lobbyPeersList of peerIds in lobby who are waiting to join a locked roomstring[]
admitPeerAdmit a peer into the room.voidpeerId: string
denyPeerDeny a peer from joining the room.voidpeerId: string
getLobbyPeerMetadataReturns the metadata of lobby peer.voidpeerId: string

Example Usage

import { useLobby } from '@huddle01/react/hooks';
 
const {
    lobbyPeers,
    admitPeer,
    denyPeer,
    getLobbyPeerMetadata
  } = useLobby({
     onLobbyPeersUpdated(lobbyPeers: string[]) ();
  });
 
// admit a peer into the room
const admitPeer = (peerId: string) => {
  admitPeer(peerId);
}
 
// deny a peer from joining the room
const denyPeer = (peerId: string) => {
  denyPeer(peerId);
}
 
// get metadata of a lobby peer
const getLobbyPeerMetadata = (peerId: string) => {
  getLobbyPeerMetadata(peerId);
}

Props

The useLobby hook accepts an object with the following fields as props.

onLobbyPeersUpdated

Optional
DescriptionReturn Type
This function will be called when the peers waiting in lobby are updated.void
Parameter NameTypeDescriptionRequired
lobbyPeersstring[]Array of peerIds of peers waiting in lobbyYes

Example Usage

const lobby = useLobby({ onLobbyPeersUpdated: (lobbyPeers) => {
	console.log("Peers in lobby who are waiting to join updated!");
    console.log(lobbyPeers);
    // your code here
}});
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.