Skip to content

Expose participantIdentity on DataReceivedEvent - #1256

Merged
hiroshihorie merged 4 commits into
mainfrom
port/js-2092-data-received-identity
Oct 26, 2026
Merged

hiroshihorie merged 4 commits into
mainfrom
port/js-2092-data-received-identity

Conversation

@xianshijing-lk

@xianshijing-lk xianshijing-lk commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Port of livekit/client-sdk-js#2092.

The gap

DataReceivedEvent.participant is null whenever the sender is not in remoteParticipants. The engine has the sender's identity on the packet but dropped it when building the event, so in that case the receiver could not tell who sent the data.

This happens in normal use, not just edge cases:

  • Join race. The server announces a participant to its peers only once it is active, but the joiner's data channel is already open. Anything it sends in that window arrives before the ParticipantUpdate that would let the receiver resolve it. livekit/rust-sdks#1574 measured about two seconds on a local server.
  • Sender already left. Data that arrives after the sender's disconnect has been processed.

The fix

Add participantIdentity to DataReceivedEvent, filled from the packet for every event, whether or not the sender resolves to a RemoteParticipant. Apps can use it to attribute or buffer data from a sender the room does not know yet.

It is empty for data sent through the Server API (SendDataRequest has no identity field) and for data sent by hidden participants, because the server clears the identity in both cases.

toString() now includes the identity.

API

The new constructor parameter defaults to '', so the constructor stays source compatible and this ships as a patch. Room is the only producer and always passes the identity. A TODO marks the constructor to become @internal, with the parameter required, in the next major release.

Verification

test/core/data_received_identity_test.dart delivers a packet from an identity that is not a room participant and checks that participant is null while the identity still arrives. A second case covers a known participant. Removing the identity from the event in Room makes both cases fail.

DataReceivedEvent carries a nullable RemoteParticipant, which is null
whenever the sender is not in remoteParticipants - data sent through the
Server API, or by a participant that has already left. In that case the
receiver had no way at all to tell who sent the data, even though the
engine had the identity in hand at the construction site.

Add participantIdentity, populated from the data packet for every event.

Port of livekit/client-sdk-js#2092.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

@github-actions

This comment has been minimized.

xianshijing-lk and others added 3 commits October 23, 2026 16:57
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A required named parameter breaks existing DataReceivedEvent callers and
would make this a major release. The engine is the only producer and
always passes the identity, so defaulting it keeps the change additive
and the patch bump honest. Matches the Android port.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add TODO to tighten the DataReceivedEvent constructor in the next major

Document when DataReceivedEvent.participantIdentity is empty

Point DataReceivedEvent doc to participantIdentity
@hiroshihorie
hiroshihorie merged commit 9d8d488 into main Oct 26, 2026
15 checks passed
@hiroshihorie
hiroshihorie deleted the port/js-2092-data-received-identity branch October 26, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants