Send Data

The sendData method allows the Local Peer to send data messages to other peers in the room. It is limited to 280 characters per message.

Parameters

NameTypeDescription
tostring[] | "*"An array of peer IDs or "*" for all peers.
payloadstringThe data message to send (limited to 1KB).
labelstringThe label of the data message.

Events

NameDescriptionReturns
receive-dataTriggered when data is received.TDataMessage
receive-volatile-dataInvoked when a new volatile data message is received from the other Remote Peers{ data: TDataMessage }

Example

// Send a message to specific peers
huddleClient.localPeer.sendData( to: ["peerID1", "peerID2"], payload: "Hello, everyone!", label: 'chat' );
 
// Sending message to all peers
huddleClient.localPeer.sendData( to: "*", payload: "Hello, everyone!", label: 'greeting' );
 
// Listen for data messages
huddleClient.localPeer.on('receive-data', (data) => {
    console.log(data);
});
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.