voicechat. senddatapacket Asynchronous
Pass a raw buffer to a voice-related WebRTC channel. The default channel carries culling messages; choose rtp only for a complete encoded RTP packet.
Luau
voicechat.senddatapacket(bytes: buffer, channel: ("data" | "rtp")?) -> booleanParameters
| Parameter | Type | Description |
|---|---|---|
bytes | buffer | Buffer containing the exact bytes to send. |
channel | ("data" | "rtp")? | Optional "data" or "rtp"; defaults to "data". |
Returns
booleanFor data, whether WebRTC accepted the immediate send. For rtp, whether the packet was queued.
Usage notes
The data channel is not audible to other players. It sends binary bytes as supplied.
The rtp path does not encode audio or build an RTP header. It waits for an outgoing RTP send and then forwards the queued bytes with that sender’s transport options. There can be up to 128 queued RTP packets.
The data buffer must contain 1–65536 bytes; an RTP buffer must contain 1–4096 bytes.
Example
Luau
local cullingMessage = buffer.fromstring("hello")
print(voicechat.senddatapacket(cullingMessage))
-- voicechat.senddatapacket(encodedRtpPacket, "rtp")