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 { Button, View } from 'react-native';
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 (
    <View>
        <View style={styles.button}>
            <Button
                title="Send data to all peers"
                onPress={sendDataToAllPeers}
            />
        </View>
        <View style={styles.button}>
            <Button
                title="Send data to specific peer"
                onPress={sendDataToSpecificPeer}
            />
        </View>
    </View>
)
};
 
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.