Skip to content

Send ReadyForRoomEvent after Connect to flush queued room events#282

Merged
xianshijing-lk merged 3 commits into
mainfrom
max/ffi-ready-for-room-event
May 22, 2026
Merged

Send ReadyForRoomEvent after Connect to flush queued room events#282
xianshijing-lk merged 3 commits into
mainfrom
max/ffi-ready-for-room-event

Conversation

@MaxHeimbrock
Copy link
Copy Markdown
Contributor

@MaxHeimbrock MaxHeimbrock commented May 15, 2026

Dependency

Depends on: livekit/rust-sdks#1068 - have to check why this even passes one of the two test suites without.

Should be reviewed once I bump the Rust FFI to the new release 0.12.59 that will have the depending change.

Summary

  • Room.OnConnect now sends the new FFI ReadyForRoomEventRequest after subscribing to FfiClient.RoomEventReceived and before firing the public Connected event, completing the new ready-handshake the Rust SDK requires.
  • Adds a PlayMode regression test (LateJoinTrackSubscriptionTests) that publishes 2 audio + 2 video tracks first, then connects a late joiner with TrackSubscribed pre-wired, and asserts every snapshot publication produces exactly one TrackSubscribed event.
  • Regenerates the C# proto bindings (the new request/response, plus mechanical drift from running protoc 34 against the current Rust protos) and patches DataTrack.cs for the DataTrackStreamEOS.error field type change.

Why

Without ReadyForRoomEventRequest, room events emitted between ConnectCallback and the C# listener registration could be silently dropped — late joiners would miss TrackSubscribed / ParticipantConnected for state that already existed at connect time. The new Rust contract (on client-sdk-rust branch ladvoc/ffi-event-flush) makes this deterministic: the connect task parks for 1 s waiting for ReadyForRoomEventRequest and disconnects the room with ConnectionTimeout if it never arrives. This PR ports that contract to the Unity SDK.

🤖 Generated with Claude Code

The Rust FFI now parks the connect task after sending ConnectCallback and
only spawns event-forwarding tasks once the client sends
ReadyForRoomEventRequest. Without it, room events emitted between Connect
and the C# listener registration were dropped (late-join scenario), and
on the new Rust SDK the room is closed with ConnectionTimeout after 1s.

Room.OnConnect now sends the ready request immediately after subscribing
to FfiClient.RoomEventReceived and before firing the public Connected
event. Adds a PlayMode regression test that publishes 4 tracks before a
subscriber joins late and asserts every TrackSubscribed event arrives
exactly once.

Proto bindings regenerated via Scripts~/generate_proto.sh against the
new ffi.proto / room.proto. DataTrack.cs consumer updated for the
DataTrackStreamEOS.error field type change (string -> message).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@MaxHeimbrock MaxHeimbrock marked this pull request as draft May 20, 2026 10:51
Copy link
Copy Markdown
Contributor

@xianshijing-lk xianshijing-lk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it locally. I am landing it to avoid breaking the functionalities

@xianshijing-lk xianshijing-lk marked this pull request as ready for review May 22, 2026 23:48
@xianshijing-lk xianshijing-lk merged commit a7a1f33 into main May 22, 2026
15 checks passed
@xianshijing-lk xianshijing-lk deleted the max/ffi-ready-for-room-event branch May 22, 2026 23:48
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