<@U084APK40NS> if the participant leaves, can we s...
# ask-ai
a
@millions-hair-24956 if the participant leaves, can we subscribe to the event and end the call, how do we do that?
g
To handle a participant leaving and subsequently end the call, you can subscribe to the
participant_disconnected
event. This event can be listened to using the
on
method of the
Room
object in LiveKit. When this event is triggered, you can execute a function to end the call or perform any necessary cleanup. Here's a basic example in Python:
Copy code
def on_participant_disconnected(participant):
    print(f"Participant disconnected: {participant.identity}")
    # Add logic to end the call or perform cleanup here

ctx.room.on("participant_disconnected", on_participant_disconnected)
This code sets up an event listener for when a participant disconnects, allowing you to handle the disconnection appropriately. Would you like more details on implementing this in a specific context or language? Sources: - LiveKit Python SDK Documentation - Slack Discussion on Participant Disconnection 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
a
@millions-hair-24956 if a participant has been SIP Transferred, is there a participant_disconnected event?
g
It seems likely that when a participant is SIP transferred using the
TransferSIPParticipant
API, the participant will leave the LiveKit room, which should trigger the
participant_disconnected
event. This is because a SIP transfer typically involves moving the participant out of the current session, effectively disconnecting them from the room. Would you like more detailed information on how SIP transfers work in LiveKit or how to handle the
participant_disconnected
event in this context? Sources: - https://docs.livekit.io/python/livekit/rtc/room.html#parameters - https://livekit-users.slack.com/archives/C07FVFM5NA1/p1729704710.265049 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.