useLobby

useLobby

Acess the following methods & states joinLobby() leaveLobby() isLoading isLobbyJoined error .

NameTypeDescription
joinLobby(roomId: string, accessToken: string)Functionmoves the user to a pre-room lobby where they can toggle with audio/video controls before joining a room
leaveLobby()Functionremoves the user from the lobby back to the initialized state
isLoadingbooleanloading state
isLobbyJoinedbooleanstate for whether the user has joined the lobby
previewPeersObjectlist of peers present in the room
errorstringgives the error message

Sample Code

 
  import { useLobby } from '@huddle01/react/hooks';
  
  const App = () => {
    const { joinLobby,leaveLobby, isLoading, isLobbyJoined, previewPeers, error } = useLobby();
 
    if(isLoading) return (<div>...loading</div>)
  
    return (
      <div>
        <button 
          disabled={!joinLobby.isCallable} 
          onClick={() => joinLobby('YOUR_ROOM_ID');
        }>
          Join Lobby
        </button>
 
        {isLobbyJoined ? "lobby": error} 
 
        <div>PreviewPeers: {JSON.stringify(previewPeers)}</div>
 
        <button disabled={!leaveRoom.isCallable} onClick={leaveRoom}>
          LEAVE_LOBBY 
        </button>
      </div>
    );
  };
 
 
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.