File tree Expand file tree Collapse file tree 2 files changed +8
-23
lines changed Expand file tree Collapse file tree 2 files changed +8
-23
lines changed Original file line number Diff line number Diff line change 16
16
17
17
import Foundation
18
18
19
- let publishOnBehalfAttributeKey = " lk.publish_on_behalf "
20
-
21
19
public extension Participant {
22
20
@objc
23
21
var isAgent : Bool {
@@ -27,13 +25,6 @@ public extension Participant {
27
25
}
28
26
}
29
27
30
- /// Avatar workers publish audio and video on behalf of the agent.
31
- /// They should not be used for other purposes or displayed to the user.
32
- @objc
33
- var isAvatarWorker : Bool {
34
- attributes. keys. contains ( publishOnBehalfAttributeKey)
35
- }
36
-
37
28
@objc
38
29
var agentState : AgentState {
39
30
guard isAgent else { return . unknown }
Original file line number Diff line number Diff line change 16
16
17
17
import Foundation
18
18
19
+ let publishOnBehalfAttributeKey = " lk.publish_on_behalf "
20
+
19
21
public extension Room {
20
- /// All agent participants in the Room, excluding avatar workers
22
+ /// All agent participants in the Room
21
23
var agentParticipants : [ Participant . Identity : RemoteParticipant ] {
22
- remoteParticipants. filter { $0. value. isAgent && !$0. value. isAvatarWorker }
24
+ // Filter out agents that are replaced by another agent e.g. avatar worker
25
+ let onBehalf = Set ( remoteParticipants. map ( \. value. attributes [ publishOnBehalfAttributeKey] ) . compactMap { $0 } )
26
+ return remoteParticipants. filter { $0. value. isAgent && !onBehalf. contains ( $0. key. stringValue) }
23
27
}
24
28
25
- /// The first agent participant in the Room, excluding avatar workers
26
- var agentParticipant : RemoteParticipant ? {
29
+ /// The first agent participant in the Room
30
+ var agentParticipant : Participant ? {
27
31
agentParticipants. values. first
28
32
}
29
-
30
- /// All avatar workers in the Room
31
- var avatarWorkers : [ Participant . Identity : RemoteParticipant ] {
32
- remoteParticipants. filter { $0. value. isAgent && $0. value. isAvatarWorker }
33
- }
34
-
35
- /// The first avatar worker in the Room
36
- var avatarWorker : RemoteParticipant ? {
37
- avatarWorkers. values. first
38
- }
39
33
}
You can’t perform that action at this time.
0 commit comments