useLocalPeer
The useLocalPeer hook allows you to interact with your own Peer object, which is how you are represented inside a Huddle01 room.
const {
peerId,
metadata,
permissions,
updateMetadata,
} = useLocalPeer({
onMetadataUpdated(metadata) {},
});
Props
The useLocalPeer hook accepts an object with the following fields as props.
1. onMetadataUpdatedOptionalAdvanced
Description | Return Type |
---|---|
This function will be called when the metadata associated with you is updated. | void |
Parameter Name | Type | Description | Required |
---|---|---|---|
metadata | unknown | The metadata associated with your peer object. | Yes |
Example Usage
const localPeer = useLocalPeer({ onMetadataUpdated: (metadata) => {
console.log("Your metadata was updated!");
console.log(metadata);
// your code here
}});
Returns
The useLocalPeer hook returns an object with the following fields.
1. peerIdObject
Description | Type |
---|---|
Your peerId. | string | null |
2. metadataObjectAdvanced
Description | Type |
---|---|
The metadata associated with you. | unknown |
3. permissionsObject
Description | Type |
---|---|
Your peer permissions inside the room. | TPermissions |
4. updateMetadataFunction
Description | Return Type |
---|---|
Update the metadata associated with your peer object. | void |
Parameter Name | Type | Description | Required |
---|---|---|---|
data | unknown | The metadata you want to be associated with your peer object. | Yes |