Shinigami Hooks
useRoom

useRoom

The useRoom hook exposes primitives to interact with a Huddle01 room, like joining, leaving, closing the room.

const {
    room,
    state,
    joinRoom,
    leaveRoom,
    closeRoom,
  } = useRoom({
    onJoin(data) {},
    onClose() {},
    onLeave() {},
  });

Props

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

1. onJoinOptional
DescriptionReturn Type
This function will be called when you successfully join a room.void
Parameter NameTypeDescriptionRequired
data{ room: Room }Object containing data about the room.Yes
Example Usage
const room = useRoom({ onJoin: (data) => {
	console.log("Successfully joined the room!");
	console.log(data.room);
    // your code here
}});
2. onLeaveOptional
DescriptionReturn Type
This function will be called when you successfully leave a room.void
Example Usage
const room = useRoom({ onLeave: () => {
	console.log("Successfully left the room!");
    // your code here
}});
3. onCloseOptional
DescriptionReturn Type
This function will be called when the room has been closed.void
Example Usage
const room = useRoom({ onClose: () => {
	console.log("The room was closed!");
    // your code here
}});
DescriptionReturn Type
This function will be called when the room controls have been updated.void
Parameter NameTypeDescriptionRequired
dataTNewRoomControlsObject containing the new room controls.Yes
Example Usage
const room = useRoom({ onJoin: (data) => {
	console.log("Room controls updated!");
	console.log(data);
    // your code here
}});

Returns

The useRoom hook returns an object with the following fields.

1. roomObject
DescriptionType
The currently joined room object.Room
2. stateObject
DescriptionType
The state of the currently joined room.RoomStates
3. joinRoomFunction
DescriptionReturn Type
Join the room.Promise<Room>
Parameter NameTypeDescriptionRequired
data{ roomId: string; token: string }Object containing the roomId to be joined and the user’s access token.Yes
4. leaveRoomFunction
DescriptionReturn Type
Leave the room.void
5. closeRoomFunction
DescriptionReturn Type
Close the room.void
Audio/Video Infrastructure designed for the developers to empower them ship simple yet powerful Audio/Video Apps.
support
company
Copyright © 2022 Graphene 01, Inc. All Rights Reserved.