steep-balloon-41261
02/12/2025, 10:22 PMgray-monkey-83525
02/12/2025, 10:22 PMpublishData
method. This method allows you to send data packets with a specified topic, which can be used to categorize the data being sent.
Here's a basic example in JavaScript:
const data = new TextEncoder().encode('your custom data');
room.localParticipant.publishData(data, { reliable: true, topic: 'custom-data' });
On the server side, you can listen for these data packets and handle them accordingly. For example, in Python:
@ctx.room.on("data_received")
def on_data_received(data: rtc.DataPacket):
if data.topic == "custom-data":
message = data.data.decode("utf-8")
# Process the message
Would you like more details on this process?
Sources:
- LiveKit Data Messages 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.