Local Peer

localPeer object from huddleClient allows you to intereact with your own Peer object, which is how you are represented in the Huddle01 room.

Metadata

The updateMetadata method enables the Local Peer to update its metadata. You can add any custom metadata you want to the Local Peer.

// Update the metadata of the Local Peer
huddleClient.localPeer.updateMetadata({ 
    displayName: "TEST",
    avatarUrl: "AVATAR_URL"
 });
 
// Get the metadata of the Local Peer
const metadata = huddleClient.localPeer.metadata;
Event NameDescriptionReturns
metadata-updatedTriggered when metadata is updatedmetadata: unknown

updateRole

updateRole update the role of the Local Peer in the Room, this will emit an event updated with the updated role.

Parameters

ParamsTypeDescriptionReturn Type
rolestringupdate the role of the Local Peer in the Roomvoid

Example

// Usage
await huddleClient.localPeer.updateRole({role:string});

Events

Event NameDescriptionReturns
metadata-updatedInvoked when a local user metadata successfully updates.{ metadata: unknown }
permissions-updatedInvoked when a local user permissions successfully updates.{ permissions: TPermissions; role?: string }
role-updatedInvoked when a local user's role successfully updates.{ role: string }
stream-fetchedInvoked when a local peer stream is fetched.{ mediaKind: 'cam' | 'mic' | 'speaker', stream: MediaStream, label: string }
stream-closedInvoked when a local peer stream is closed.{ label: string, mediaKind: 'cam' | 'mic' | 'speaker', reason?: { code: number, tag: string, message: string } }
stream-playableInvoked when a local peer stream is playable.{ label: string, producer: Producer }
device-createdInvoked when a new device is created{ device: Device }
new-recv-transportInvoked when a local peer is ready to consume stream{ transport: Transport }
new-send-transportInvoked when a local peer is ready to produce stream{ transport: Transport }
receive-dataInvoked when a new data message is received from the other Remote Peers{ data: TDataMessage }
receive-volatile-dataInvoked when a new volatile data message is received from the other Remote Peers{ data: TDataMessage }
reconnectedInvoked when a local peer is reconnected.{ data: Socket }

Example

 
// Event listeners for the Remote Peer
localPeer.on("metadata-updated", () => {
  console.log("successfully updated remote peer metatdat.");
});
 
localPeer.once("stream-available", (data) => {
  console.log("Remote Peer stream is avaialble.");
 
});
 
localPeer.off("stream-closed", () => {
  console.log("Remote Peer Stream is closed.");
});
Audio/Video Infrastructure designed for the developers to empower them ship simple yet powerful Audio/Video Apps.
support
company
Copyright © 2024 Graphene 01, Inc. All Rights Reserved.