useRemotePeer
The useRemotePeer hook allows you to interact with another user's Peer object, which is how they are represented inside a Huddle01 room.
const {
peerId,
metadata,
} = useRemotePeer({
peerId: "remote-peer-id",
onMetadataUpdate(data) {},
});
Props
The useRemotePeer hook accepts an object with the following fields as props.
1. peerIdRequired
Description | Type |
---|---|
The peerId of the remote peer. | string |
Example Usage
const remotePeer = useRemotePeer({ peerId: "remote-peer-id" });
2. onMetadataUpdatedOptionalAdvanced
Description | Return Type |
---|---|
This function will be called when the metadata associated with the remote peer is updated. | void |
Parameter Name | Type | Description | Required |
---|---|---|---|
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
}});
Returns
The useLocalPeer hook returns an object with the following fields.
1. peerIdObject
Description | Type |
---|---|
The remote peer's peerId. | string | undefined |
2. metadataObjectAdvanced
Description | Type |
---|---|
The metadata associated with the remote peer. | unknown |