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
Name | Type | Description |
---|---|---|
to | string[] or "" | An array of peer IDs or "" for all peers. |
payload | string | The data message to send (limited to 280 characters). |
Events
Name | Description | Returns |
---|---|---|
data-message | Triggered when a data message is received. | { peerId: string; label: string; message: string } |
receive-data | Triggered when data is received. | TDataMessage |
Example
// Send a message to specific peers
huddleClient.localPeer.sendData({ to: ["peerID1", "peerID2"], payload: "Hello, everyone!" });
// Sending message to all peers
huddleClient.localPeer.sendData({ to: "*", payload: "Hello, everyone!" });