Skip to content

Commit

Permalink
return None for disconnect reason
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzhao committed Dec 30, 2024
1 parent 3c70bc4 commit 940bafb
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions livekit-rtc/livekit/rtc/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,30 @@ def kind(self) -> proto_participant.ParticipantKind.ValueType:
return self._info.kind

@property
def disconnect_reason(self) -> proto_participant.DisconnectReason.ValueType:
"""Reason for the participant's disconnection."""
def disconnect_reason(
self,
) -> Optional[proto_participant.DisconnectReason.ValueType]:
"""Reason for the participant's disconnection.
Returns one of DisconnectReasons or None if the participant isn't disconnected. Common reasons are:
- CLIENT_INITIATED - the client initiated the disconnect
- DUPLICATE_IDENTITY - another participant with the same identity has joined the room
- SERVER_SHUTDOWN - the server instance is shutting down
- PARTICIPANT_REMOVED - RoomService.RemoveParticipant was called
- ROOM_DELETED - RoomService.DeleteRoom was called
- STATE_MISMATCH - the client is attempting to resume a session, but server is not aware of it
- JOIN_FAILURE - client was unable to connect fully
When dialing a participant via SIP, you may see the following reasons:
- USER_UNAVAILABLE - SIP callee did not respond in time
- USER_REJECTED - SIP callee rejected the call (busy)
- SIP_TRUNK_FAILURE - SIP protocol failure or unexpected response
"""
if (
self._info.disconnect_reason
== proto_participant.DisconnectReason.DISCONNECT_REASON_UNKNOWN
):
return None
return self._info.disconnect_reason


Expand Down

0 comments on commit 940bafb

Please sign in to comment.