What is the event that ocurres when a participant ...
# ask-ai
r
What is the event that ocurres when a participant information is updated? If this ocurres when a participant joins and prints their information
Copy code
@ctx.room.on("participant_connected")
    def on_participant_connected(participant: rtc.RemoteParticipant):
        <http://logger.info|logger.info>(f"new participant joined {participant.identity}")
What is the equivalent that fires when there is a change on the participant identity or attributes?
t
Thanks for reaching out, Santiago. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
In LiveKit, the event that occurs when a participant's information is updated depends on the specific type of update: • Metadata Updates: Use the event for metadata changes, such as
participant(_:didUpdateMetadata:)
in Swift or
ParticipantMetadataUpdatedEvent
in Flutter. • Attribute Updates: For changes in participant attributes, you can use
participant(_:didUpdateAttributes:)
in Swift or
RoomEvent.ParticipantAttributesChanged
in JavaScript. • Name Updates: For name changes, use
participant(_:didUpdateName:)
in Swift or
ParticipantNameUpdatedEvent
in Flutter. These events allow you to handle updates to participant information dynamically. Let me know if you need further clarification or examples! Sources: Documentation | livekit_client library - Dart API | participant(_:didUpdateName:) | Documentation | ParticipantDelegate | Documentation | Participant attributes and metadata | LiveKit Docs
r
Great! give me the code for python
t
Hey there! I totally get your confusion about participant updates in the LiveKit Python SDK. While there isn't a specific event for participant info changes, you can actually use the
update_participant
method to modify participant details. Check out this handy example:
Copy code
async def update_participant(self, update: UpdateParticipantRequest) -> ParticipantInfo:
    """Updates a participant's metadata or permissions.

    Args:
        update (UpdateParticipantRequest): arg containing:
        - room: str - Room name
        - identity: str - Participant identity
        - metadata: str - New metadata
        - permission: ParticipantPermission - New permissions
        - name: str - New display name
        - attributes: dict[str, str] - Key-value attributes

    Returns:
        ParticipantInfo: Updated participant information
    """
I know it might not be exactly what you were hoping for in terms of real-time updates, but this method can help you manage participant information. Want to chat more about how we can work around this? I'm here to help! Sources: livekit.api.room_service API documentation