chilly-motorcycle-32290
08/04/2025, 9:32 AMtall-airline-16756
08/04/2025, 9:32 AMtall-airline-16756
08/04/2025, 9:32 AMpublishData in LiveKit, the following criteria must be met:
• Room Connection: You must have an active connection to a LiveKit room. This is managed through the LocalParticipant instance, which becomes available after successfully joining a room.
• Permissions: The participant must have the necessary permissions to publish data, which are configured in the room's access control settings.
• Data Format: The data must be in a supported format, such as a Uint8Array or string, and must not exceed size limits (15KiB for reliable delivery, 1300 bytes for lossy delivery).
• Delivery Options: You can specify reliable or lossy delivery and target specific participants using the destinationIdentities parameter.
In summary, the room being available is not sufficient; you must also have an active session (i.e., be connected to the room) to use publishData.
Sources: Data messages | LiveKit Docs | Sources/LiveKit/Participant/LocalParticipant.swiftchilly-motorcycle-32290
08/04/2025, 9:33 AMtall-airline-16756
08/04/2025, 9:38 AMpublishData function let you send data directly to specific participants in a room. So instead of sharing your data with everyone, you can choose exactly who should get it by listing their identities in the destinationIdentities parameter.
Here’s what you need to know:
• If you provide destinationIdentities, only those participants will receive the data.
• If you leave it empty, the data goes to everyone in the room by default.
Here’s a quick example:
// Send data to specific participants
room.localParticipant.publishData(data, {
reliable: true,
destinationIdentities: ['participant1', 'participant2']
});
This is super handy when you want to send direct messages or share data based on roles within the room.