Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changes/last-spoke-at
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patch type="added" "Add lastSpokeAt property to Participant"
6 changes: 6 additions & 0 deletions Sources/LiveKit/Core/Room+EngineDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,19 @@ extension Room {
if participantSid == localParticipant.sid {
localParticipant._state.mutate {
$0.audioLevel = speaker.level
if !$0.isSpeaking {
$0.lastSpokeAt = Date()
}
$0.isSpeaking = true
}
activeSpeakers.append(localParticipant)
} else {
if let participant = state.remoteParticipant(forSid: participantSid) {
participant._state.mutate {
$0.audioLevel = speaker.level
if !$0.isSpeaking {
$0.lastSpokeAt = Date()
}
$0.isSpeaking = true
}
activeSpeakers.append(participant)
Expand Down
3 changes: 3 additions & 0 deletions Sources/LiveKit/Core/Room+SignalClientDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ extension Room: SignalClientDelegate {

participant._state.mutate {
$0.audioLevel = speaker.level
if !$0.isSpeaking, speaker.active {
$0.lastSpokeAt = Date()
}
$0.isSpeaking = speaker.active
}

Expand Down
4 changes: 4 additions & 0 deletions Sources/LiveKit/Participant/Participant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public class Participant: NSObject, @unchecked Sendable, ObservableObject, Logga
@objc
public var isSpeaking: Bool { _state.isSpeaking }

@objc
public var lastSpokeAt: Date? { _state.lastSpokeAt }

@objc
public var metadata: String? { _state.metadata }

Expand Down Expand Up @@ -88,6 +91,7 @@ public class Participant: NSObject, @unchecked Sendable, ObservableObject, Logga
var name: String?
var audioLevel: Float = 0.0
var isSpeaking: Bool = false
var lastSpokeAt: Date?
var metadata: String?
var joinedAt: Date?
var kind: Kind = .unknown
Expand Down
Loading