useRoomControls
The useRoomControls hook allows you to read and update the room's controls.
const {
room,
state,
joinRoom,
leaveRoom,
closeRoom,
} = useRoomControls({
onJoin(data) {},
onClose() {},
onLeave() {},
});
Props
The useRoomControls hook accepts an object with the following fields as props.
1. onRoomControlsUpdatedOptionalAdvanced
Description | Return Type |
---|---|
This function will be called when the room controls have been updated. | void |
Parameter Name | Type | Description | Required |
---|---|---|---|
data | TNewRoomControls | Object containing the new room controls. | Yes |
Example Usage
const roomControls = useRoomControls({ onJoin: (data) => {
console.log("Room controls updated!");
console.log(data);
// your code here
}});
Returns
The useRoomControls hook returns an object with the following fields.
1. roomControlsObjectAdvanced
Description | Type |
---|---|
The state of the currently joined room. | TRoomControls |
2. updateControlsFunctionAdvanced
Description | Return Type |
---|---|
Update the room control. | void |
Parameter Name | Type | Description | Required |
---|---|---|---|
data | TNewRoomControls | Object containing the type of room control to be updated and it’s new value. | Yes |