Skip to content

Commit 940bafb

Browse files
committed
return None for disconnect reason
1 parent 3c70bc4 commit 940bafb

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

livekit-rtc/livekit/rtc/participant.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,30 @@ def kind(self) -> proto_participant.ParticipantKind.ValueType:
108108
return self._info.kind
109109

110110
@property
111-
def disconnect_reason(self) -> proto_participant.DisconnectReason.ValueType:
112-
"""Reason for the participant's disconnection."""
111+
def disconnect_reason(
112+
self,
113+
) -> Optional[proto_participant.DisconnectReason.ValueType]:
114+
"""Reason for the participant's disconnection.
115+
116+
Returns one of DisconnectReasons or None if the participant isn't disconnected. Common reasons are:
117+
- CLIENT_INITIATED - the client initiated the disconnect
118+
- DUPLICATE_IDENTITY - another participant with the same identity has joined the room
119+
- SERVER_SHUTDOWN - the server instance is shutting down
120+
- PARTICIPANT_REMOVED - RoomService.RemoveParticipant was called
121+
- ROOM_DELETED - RoomService.DeleteRoom was called
122+
- STATE_MISMATCH - the client is attempting to resume a session, but server is not aware of it
123+
- JOIN_FAILURE - client was unable to connect fully
124+
125+
When dialing a participant via SIP, you may see the following reasons:
126+
- USER_UNAVAILABLE - SIP callee did not respond in time
127+
- USER_REJECTED - SIP callee rejected the call (busy)
128+
- SIP_TRUNK_FAILURE - SIP protocol failure or unexpected response
129+
"""
130+
if (
131+
self._info.disconnect_reason
132+
== proto_participant.DisconnectReason.DISCONNECT_REASON_UNKNOWN
133+
):
134+
return None
113135
return self._info.disconnect_reason
114136

115137

0 commit comments

Comments
 (0)