Skip to content

Commit daa2e7d

Browse files
committed
Documented that sids should be compared on state changeds
1 parent 8ddbc72 commit daa2e7d

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

‎livekit-session/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ code needs only the predicates on `AgentState`: `is_connected`, `is_pending` and
6666

6767
The agent's microphone and its avatar's camera are available from `agent_audio_track()` and
6868
`agent_avatar_video_track()`, for an app that wants their frames, e.g. for a visualizer or to show
69-
the avatar. `SessionState::agent_tracks` flags which of them are subscribed, so the state watch is
70-
the only signal an app needs: on each change, read the tracks again and compare them by `sid`, as a
71-
track can be replaced while its flag stays set.
69+
the avatar. `SessionState::agent_tracks` flags which of them are subscribed: read the tracks again
70+
when a flag changes. In edge cases, e.g. an avatar reconnecting, a track can be replaced without its
71+
flag changing, so compare tracks by `sid` whenever you read them.
7272

7373
## Messages
7474

‎livekit-session/src/agent.rs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,9 @@ pub enum AgentFailure {
133133
/// These are flags, not the tracks: get those from
134134
/// [`Session::agent_audio_track`](crate::Session::agent_audio_track) and
135135
/// [`Session::agent_avatar_video_track`](crate::Session::agent_avatar_video_track).
136-
/// Call them again on every change of [`SessionState`](crate::SessionState),
137-
/// not only when a flag changes: a track that is replaced, e.g. when the
138-
/// avatar reconnects, can leave its flag `true`. Compare tracks by their
139-
/// `sid` to find a replacement.
136+
/// Read them again when a flag changes. In edge cases, e.g. an avatar
137+
/// reconnecting, a track can be replaced without its flag changing, so
138+
/// compare tracks by their `sid` whenever you read them.
140139
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
141140
#[non_exhaustive]
142141
pub struct AgentTracks {

0 commit comments

Comments
 (0)