Skip to content

Expose DisconnectReason on Room#320

Open
MaxHeimbrock wants to merge 2 commits into
mainfrom
max/disconnect-reason
Open

Expose DisconnectReason on Room#320
MaxHeimbrock wants to merge 2 commits into
mainfrom
max/disconnect-reason

Conversation

@MaxHeimbrock

Copy link
Copy Markdown
Contributor

Summary

The Disconnected and ParticipantDisconnected FFI events already carry a DisconnectReason, but it was dropped before reaching the public C# API — there was no way to read why a room or participant disconnected.

This surfaces it without breaking existing subscribers:

  • Room.DisconnectReason property, set immediately before the Disconnected event fires.
  • Room.DisconnectedWithReason event (Room, DisconnectReason) alongside the existing parameterless Disconnected.
  • Room.ParticipantDisconnectedWithReason event (Participant, DisconnectReason) alongside the existing ParticipantDisconnected.
  • Meet sample wired up to log the reason on both room and participant disconnect.

Existing Disconnected / ParticipantDisconnected signatures are unchanged, so current code keeps compiling.

Usage

room.Disconnected += r => Debug.Log($"Disconnected: {r.DisconnectReason}");
room.ParticipantDisconnectedWithReason += (p, reason) =>
    Debug.Log($"{p.Identity} left: {reason}");

Testing

Project opens and compiles cleanly in Unity.

🤖 Generated with Claude Code

The Disconnected and ParticipantDisconnected FFI events already carry a
DisconnectReason, but it was dropped before reaching the public API.

- Add Room.DisconnectReason, set from the Disconnected event.
- Add Room.DisconnectedWithReason (Room, DisconnectReason) alongside the
  existing parameterless Disconnected event.
- Add Room.ParticipantDisconnectedWithReason (Participant, DisconnectReason)
  alongside the existing ParticipantDisconnected event.
- Wire both into the Meet sample to log the reason.

Existing event signatures are unchanged, so subscribers keep working.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@MaxHeimbrock MaxHeimbrock requested a review from cloudwebrtc June 19, 2026 15:30
@MaxHeimbrock

MaxHeimbrock commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

As from #53
@cloudwebrtc

Tested:

Room:
Screenshot 2026-06-19 at 17 28 07

Participant:
Screenshot 2026-06-19 at 17 30 43

Drive Room.OnEventReceived with synthetic Disconnected and
ParticipantDisconnected FFI events to verify the reason reaches
Room.DisconnectReason, DisconnectedWithReason, and
ParticipantDisconnectedWithReason. Also covers the default
(UnknownReason) value. No server required.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

1 participant