useRemotePeer

useRemotePeer

The useRemotePeer hook allows you to interact with another user's Peer object, which is how they are represented inside a Huddle01 room.

NameDescriptionReturn TypeParams
peerIdThe peerId of the remote peer.void
roleThe role you want to be associated with your peer object.string
metadataThe metadata you want to be associated with your peer object.unknown
updateRoleA function that allows you to update the role associated with your peer object.voidrole: string

Example Usage

import { useRemotePeer } from "@huddle01/react/hooks";
 
const {
    peerId,
    role,
    metadata,
    updateRole,
  } = useRemotePeer({
    peerId: "remote-peer-id",
    onMetadataUpdate(data) {},
  });
 
const updateRemotePeerRole = () => {
  updateRole("speaker");
}

Props

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

peerId

Required
DescriptionType
The peerId of the remote peer.string

Example Usage

const remotePeer = useRemotePeer({ peerId: "remote-peer-id" });

onMetadataUpdated

OptionalAdvanced
DescriptionReturn Type
This function will be called when the metadata associated with the remote peer is updated.void
Parameter NameTypeDescriptionRequired
data{ metadata: unknown }An object containing the metadata associated with the remote peer object.Yes

Example Usage

const remotePeer = useRemotePeer({ peerId: "remote-peer-id", onMetadataUpdated: (data) => {
	console.log("Remote peer's metadata was updated!");
	console.log(data.metadata);
    // your code here
}});
Audio/Video Infrastructure designed for developers to empower them to ship simple yet powerful Audio/Video Apps.
support
company
Copyright © 2024 Graphene 01, Inc. All Rights Reserved.