Send Data

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
HuddleClient.Instance.SendTextMessage("*",data,label);
 
//Send data to peer in a room
HuddleClient.Instance.SendTextMessage(<peerId>,data,label);
 

HuddleClient.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()
{
    HuddleClient.OnMessageReceived += OnMessageReceived;
}    
 
private void OnDisable()
{
    HuddleClient.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.