How do you trigger an action when the remote parti...
# ask-ai
r
How do you trigger an action when the remote participant / user leaves the room / call?
t
Thanks for reaching out, Don. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To trigger an action when a remote participant leaves a room or call in LiveKit, you can use the following methods depending on your programming language: • Swift: Implement the
room(_:participantDidDisconnect:)
method from the
RoomDelegate
protocol:
Copy code
func room(_ room: Room, participantDidDisconnect participant: RemoteParticipant) {
    // Your action when a participant leaves
}
Python: Register an event handler for the
participant_disconnected
event:
Copy code
def on_participant_disconnected(participant):
    print(f"Participant disconnected: {participant.identity}")
    # Your action when a participant leaves

room.on("participant_disconnected", on_participant_disconnected)
Flutter: Listen for the
ParticipantDisconnectedEvent
emitted by the
Room
class when a
RemoteParticipant
leaves the room:
// Listen for the event and implement your action when a participant leaves
Let me know if you need further assistance with implementing this! Sources: room(_:participantDidDisconnect:) | Documentation | livekit.rtc.room API documentation | ParticipantDisconnectedEvent class - livekit_client library - Dart API