useAppUtils

useAppUtils

useAppUtils hook allows you to set displayName, avatarUrl and sendData.

You can import useAppUtils hook from @huddle01/react/app-utils

NameType
setDisplayName(displayName: string)FunctionSet the display name of the current user
changeAvatarUrl(avatarUrl: string)FunctionSet the avatar url of the current user
sendData(peerIds: [] | "*", data: unknown)FunctionSend data to the specified peerIds or all peers if '*' is passed as peerIds
errorstringError message occurs while using any function of useAppUtils hook
displayNamestringDisplay name of the current user

Example

import { useEffect } from "react";
import { useAppUtils } from "@huddle01/react/app-utils";
 
const App = () => {
 
useEffect(() => {
    if(changeAvatarUrl.isCallable) {
        changeAvatarUrl("YOUR AVATAR URL")
    }
}, [changeAvatarUrl.isCallable]);
 
useEffect(() => {
    if(setDisplayName.isCallable) {
        setDisplayName("YOUR DISPLAY NAME")
    }
}, [setDisplayName.isCallable]);
 
const sendDataToAllPeers = () => {
    sendData("*", { message: "Hello World" })
};
 
const sendDataToSpecificPeer = () => {
    sendData(["PEER_ID"], { message: "Hello World" })
};
 
return (
    <div>
        <button onClick={sendDataToAllPeers}> Send data to all peers </button>
        <button onClick={sendDataToSpecificPeer}> Send data to specific peer </button>
    </div>
)
};
 
export default App;
 
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.