SendData(string message)

Call this function to send any string data either to specific peer or all peer in the room. Pass "*" to send data to all peers in the room or peerId to specific peer in the room

Parameters

ParamsTypeDescription
tostringpeer ID or "*" for all peers.
datastringAny data or message in form of string
labelstringThe label of the data message.

Example

.csharp
//Send data to all peers in the room
Huddle01Core.Instance.SendData("*",data,label);
 
//Send data to peer in a room
Huddle01Core.Instance.SendData(<peerId>,data,label);
 

SendData(List<string> peerIds,string data, string label)

Call this function to send any string data or message to selected peers in the room.

Parameters

ParamsTypeDescription
peerIdsList<string>List of peerIds
datastringAny data or message in form of string
labelstringThe label of the data message.

Example

.csharp
public void SendData(List<string> peerIds,string data,string label)
{
    Huddle01Core.Instance.SendData(peerIds,data,label);
}

HuddleCore.OnMessageReceived

Subscribe to this event to receive message send by any peer in the room.

Parameters

ParamsTypeDescription
messagestringmessage in form of json which can be Deserialized into `MessageReceivedResponse`
.csharp
 
private void OnEnable()
{
    Huddle01Core.OnMessageReceived += OnMessageReceived;
}    
 
private void OnDisable()
{
    Huddle01Core.OnMessageReceived -= OnMessageReceived;
}
 
private void OnMessageReceived(string data)
{
    Debug.Log($"received data : {data}");
    MessageReceivedResponse response = JsonConvert.DeserializeObject<MessageReceivedResponse>(data);
}
 
 
[System.Serializable]
public class MessageReceivedResponse 
{
    [JsonProperty("from")]
    public string From;
 
    [JsonProperty("label")]
    public string Label;
 
    [JsonProperty("payload")]
    public string Payload;
}
 
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.