what is the difference between on_attributes_chang...
# ask-ai
w
what is the difference between on_attributes_changed event, and on_participant_connected event?
t
Thanks for reaching out, Arthur. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Just wanted to break down the
on_participant_connected
and
on_attributes_changed
events in LiveKit for you: •
on_participant_connected
: This one kicks in when a new participant joins the room after you’ve already connected. It gives you the participant object, which is super handy for things like updating your UI or sending a warm welcome. Just a heads-up, it won’t fire for folks who were already in the room when you joined. •
on_attributes_changed
: This event pops up whenever someone’s participant attributes get updated. You’ll get the changed attributes plus the participant object, so you can easily keep track of things like SIP call status updates or tweak participant-specific UI elements as things change during the session. If you want me to walk you through any part of this or share some examples, just give me a shout! Sources: livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Parti... | src/room/Room.ts | telephony/sip_lifecycle.py
w
whenever the callback/handler function is called for the on_attributes_changed event, what is passed in as an argument?
t
When the
on_attributes_changed
event fires, the callback function gets a couple of handy arguments: •
changed_attributes
: This is a dictionary (or map) showing which attributes have changed and their new values. If an attribute was deleted, you'll see it as an empty string. •
participant
: This is the participant object whose attributes just got updated. If you'd like me to walk you through more details or share some examples for a particular SDK, just give me a shout! Sources: callback_test.go | src/room/Room.ts | livekit-rtc/livekit/rtc/room.py | livekit/src/room/participant/mod.rs | livekit-android-sdk/src/main/java/io/livekit/android/room/participant/Parti...
w
What are the different keys in the changed_attributes dictionary?
t
The
changed_attributes
dictionary in the
on_attributes_changed
event holds app-specific key-value pairs, where both keys and values are strings. The keys tell you which attributes have changed, and the values show their updated state. Here are some examples of keys you might see: • Application-Specific Keys: For instance,
captions_language
to set the language for captions. • SIP-Related Keys: ◦ `sip.callStatus`: The current status of the SIP call (like "active" or "dialing"). ◦ `sip.callID`: The identifier for the SIP call. ◦ `sip.phoneNumber`: The phone number tied to the SIP call. ◦ `sip.trunkID`: The identifier for the SIP trunk. ◦ `sip.trunkPhoneNumber`: The phone number of the trunk. These keys are totally up to your app, so feel free to customize them however fits your needs. If you want me to walk you through more examples or clarify anything, just let me know—I'm here to help! Sources: src/room/events.ts | livekit-rtc/livekit/rtc/room.py | server/main.py | telephony/sip_lifecycle.py
w
what are the possible values, and their meanings, for the sip.callStatus key?
t
The
sip.callStatus
key tells you what's going on with a SIP call right now. Here’s a quick rundown of the possible values and what they mean: •
active
: The participant is connected, and the call is up and running. •
automation
: For outbound calls using DTMF (Dual-Tone Multi-Frequency), this means the call is connected but still dialing those DTMF numbers. Once all numbers are dialed, it switches to
active
. •
dialing
: The call is in the process of dialing and waiting for someone to pick up. •
hangup
: Someone on the call has ended it. •
ringing
: For incoming calls, this means the phone is ringing. When the SIP participant picks up and subscribes to any remote audio tracks, it changes to
active
. If you want, I’m happy to share more details or examples on how to use this in your app—just let me know! Sources: SIP participant | LiveKit Docs | Making calls using SIP | LiveKit Docs
w
Difference between remotePartiicpant and Participant?
t
Let's break down the difference between
Participant
and
RemoteParticipant
so it’s a bit easier to understand: •
Participant
: Think of this as the base class that represents anyone or anything in a LiveKit session. It includes the basics like identity, metadata, attributes, and managing tracks. You can’t create a
Participant
directly—it’s more like the foundation for other participant types. •
RemoteParticipant
: This one is a special kind of
Participant
that represents users who are joining the session remotely. It comes with extra tools to handle things like: ◦ Managing subscriptions for remote tracks. ◦ Controlling volume for remote audio tracks. ◦ Handling events such as
TrackSubscribed
,
TrackUnsubscribed
, and
TrackSubscriptionFailed
. ◦ Using
RemoteTrackPublication
objects to manage track publications. So, in a nutshell,
Participant
is the general role, and
RemoteParticipant
is tailored specifically for managing remote users in your session. If you want me to explain anything more or have questions, just let me know—I’m here to help! Sources: Rooms, participants, and tracks | LiveKit Docs | lib/src/participant/participant.dart | src/room/Room.ts