Local Peer

UpdateLocalPeerMetaData(string metadata)

To Update the local peer metadata, call the method Huddle01Core.Instance.UpdateLocalPeerMetaData. it takes json string of PeerMetadata class object as a parameter. Keep that in mind, in case you want to make some changes in class PeerMetadata you need to make some changes in HuddleWebglPlugin.jslib accordingly

Parameters

ParamsTypeDescription
peerMetadataPeerMetadataPeerMetadata class object holding peer metadata
.csharp
public void UpdateLocalPeerMetaData(PeerMetadata peerMetadata)
{
    Debug.Log($"UpdateLocalPeerMetaData : {JsonConvert.SerializeObject(peerMetadata)}");
    Huddle01Core.Instance.UpdateLocalPeerMetaData(JsonConvert.SerializeObject(peerMetadata));
}
 
[System.Serializable]
public class PeerMetadata
{
    [JsonProperty("peerId")]
    public string PeerId;
    [JsonProperty("muteStatus")]
    public bool MuteStatus;
    [JsonProperty("videoStatus")]
    public bool VideoStatus;
    [JsonProperty("name")]
    public string Name;
}
.jslib
UpdatePeerMeataData : function(metadataVal)
{
    var metadata = JSON.parse(UTF8ToString(metadataVal));
    huddleClient.localPeer.updateMetadata({
        peerId: metadata.peerId,
        muteStatus: metadata.muteStatus,
        muteStatus: metadata.videoStatus,
        name : metadata.name
    });
}

GetLocalPeerId()

call this method to get the localPeerId and subscribe to Huddle01Core.LocalPeerId event to handle the peerId

.csharp
private void OnEnable()
{
    Huddle01Core.LocalPeerId += OnLocalPeerIdReceived;
}
 
private void OnDisable()
{
    Huddle01Core.LocalPeerId -= OnLocalPeerIdReceived;
}
 
public void GetLocalPeerId()
{
	 Huddle01Core.Instance.GetLocalPeerId();
}
 
private void OnLocalPeerIdReceived(string peerId)
{
    Debug.Log($"Local peer id : {peerId}");
}
 

Events

LocalPeerId(string peerId)

Subscribe to this event to get localPeerId.

.csharp
 
private void OnEnable()
{
    Huddle01Core.LocalPeerId += OnLocalPeerIdReceived;
}    
 
private void OnDisable()
{
    Huddle01Core.LocalPeerId -= OnLocalPeerIdReceived;
}
 
private void OnLocalPeerIdReceived(string peerId)
{
    Debug.Log($"local peer id : {peerId}");
}
 

Classes

HuddleUserInfo

.csharp
[Serializable]
public class HuddleUserInfo
{
    public string PeerId;
    public PeerMetadata Metadata = new PeerMetadata();
    public bool IsRemotePeer;
    public string Role;
}

PeerMetadata

.csharp
[System.Serializable]
public class PeerMetadata
{
    [JsonProperty("peerId")]
    public string PeerId;
    [JsonProperty("muteStatus")]
    public bool MuteStatus;
    [JsonProperty("videoStatus")]
    public bool VideoStatus;
    [JsonProperty("name")]
    public string Name;
}
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.