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.
const {
lobbyPeers,
admitPeer,
denyPeer
} = useLobby({
onLobbyPeersUpdated(lobbyPeers) {},
});
Props
The useLobby hook accepts an object with the following fields as props.
1. onLobbyPeersUpdatedOptional
Description | Return Type |
---|---|
This function will be called when the peers waiting in lobby are updated. | void |
Parameter Name | Type | Description | Required |
---|---|---|---|
lobbyPeers | string[] | Array of peerIds of peers waiting in lobby | Yes |
Example Usage
const lobby = useLobby({ onLobbyPeersUpdated: (lobbyPeers) => {
console.log("Peers in lobby who are waiting to join updated!");
console.log(lobbyPeers);
// your code here
}});
Returns
The useLobby hook returns an object with the following fields.
1. lobbyPeersArray
Description | Type |
---|---|
List of peerIds of the peers in lobby who are waiting to join a locked room | string[] |
2. admitPeerFunction
Description | Return Type |
---|---|
Admit a peer into the room. | void |
Parameter Name | Type | Description | Required |
---|---|---|---|
peerId | string | peerId of the waiting peer you want to admit into the room. | Yes |
2. denyPeerFunction
Description | Return Type |
---|---|
Deny a peer from joining the room. | void |
Parameter Name | Type | Description | Required |
---|---|---|---|
peerId | string | peerId of the waiting peer you want to deny joining the room. | Yes |