how reliable is SendDataRequest if i set ...
# ask-ai
w
how reliable is SendDataRequest if i set kind=DataPacketKind.KIND_RELIABLE? WHat percentage of the time does it fail
t
Thanks for reaching out, Drew. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
When you use
SendDataRequest
with
kind=DataPacketKind.KIND_RELIABLE
, it’s built to be super reliable, with features like in-order delivery and automatic retries if a packet gets lost. That said, it’s important to know it can’t promise 100% delivery because things like network hiccups, client disconnections, and buffer limits can sometimes get in the way. We don’t have exact failure rate percentages to share since reliability really depends on factors like your network’s stability and how everything’s set up. While the protocol does its best with strong retry mechanisms, it works on a “best-effort” basis and might occasionally stumble, especially in tricky situations like long disconnections. Sources: Data packets | LiveKit Docs | Tests/LiveKitTests/DataStream/DataChannelTests.swift | src/room/RTCEngine.ts
w
Is there an easy way for one agent to send an ack to another telling it that it received the data sent to the troom
t
Hey there! If you want to send an acknowledgment from one agent to another in LiveKit after receiving data in a room, you can use the Remote Procedure Call (RPC) mechanism. Let me walk you through how it works: 1. Initiate an RPC Call: You can use the
performRpc
method on the
LocalParticipant
to send a request to another participant. Here’s a Swift example:
Copy code
let response = try await localParticipant.performRpc(
    destinationIdentity: anotherAgentIdentity,
    method: "confirmReceipt",
    payload: "Data received",
    responseTimeout: 10
)
1. Send an Acknowledgment: The person receiving the request can send back an acknowledgment using the
publishRpcAck
method. Here’s how you’d do it in Android:
Copy code
localParticipant.publishRpcAck(
    destinationIdentity = senderIdentity,
    requestId = requestId
)
1. Handle the Acknowledgment: Don’t forget to set up handlers to process incoming acknowledgments. Here’s an example in Flutter:
Copy code
void handleIncomingRpcAck(String requestId) {
    // Handle the acknowledgment
}
Using this approach helps keep communication smooth and reliable between agents in LiveKit. If you have any questions or need a hand with this, just let me know!
w
Do the two agents have to be in the same room? Can I do this across two different rooms?
t
LiveKit's RPC feature is built to work within a single room, so everyone in that room can chat and send acknowledgments to each other. However, RPC calls and acknowledgments don’t work across different rooms. If you want to connect participants in different rooms, you’ll need to set up a solution at the application level, outside of what LiveKit’s RPC offers. I’m here if you want to chat more about how to make that happen! Sources: Realtime data | LiveKit Docs | Sources/LiveKit/Core/Room+EngineDelegate.swift