Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Room.creationTime #535

Merged
merged 1 commit into from
Jan 9, 2025
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
8 changes: 6 additions & 2 deletions Sources/LiveKit/Core/Room+SignalClientDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,14 @@ extension Room: SignalClientDelegate {
_state.mutate {
$0.sid = Room.Sid(from: joinResponse.room.sid)
$0.name = joinResponse.room.name
$0.serverInfo = joinResponse.serverInfo
$0.creationTime = Date(timeIntervalSince1970: TimeInterval(joinResponse.room.creationTime))
$0.maxParticipants = Int(joinResponse.room.maxParticipants)

$0.metadata = joinResponse.room.metadata
$0.isRecording = joinResponse.room.activeRecording
$0.serverInfo = joinResponse.serverInfo
$0.numParticipants = Int(joinResponse.room.numParticipants)
$0.numPublishers = Int(joinResponse.room.numPublishers)

localParticipant.set(info: joinResponse.participant, connectionState: $0.connectionState)

Expand All @@ -122,7 +127,6 @@ extension Room: SignalClientDelegate {
_state.mutate {
$0.metadata = room.metadata
$0.isRecording = room.activeRecording
$0.maxParticipants = Int(room.maxParticipants)
$0.numParticipants = Int(room.numParticipants)
$0.numPublishers = Int(room.numPublishers)
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/LiveKit/Core/Room.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public class Room: NSObject, ObservableObject, Loggable {
@objc
public var activeSpeakers: [Participant] { _state.activeSpeakers }

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

/// If the current room has a participant with `recorder:true` in its JWT grant.
@objc
public var isRecording: Bool { _state.isRecording }
Expand Down Expand Up @@ -125,6 +128,7 @@ public class Room: NSObject, ObservableObject, Loggable {
var remoteParticipants = [Participant.Identity: RemoteParticipant]()
var activeSpeakers = [Participant]()

var creationTime: Date?
var isRecording: Bool = false

var maxParticipants: Int = 0
Expand Down
1 change: 0 additions & 1 deletion Sources/LiveKit/Core/SignalClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ private extension SignalClient {
_lastJoinResponse = joinResponse
_delegate.notifyDetached { await $0.signalClient(self, didReceiveConnectResponse: .join(joinResponse)) }
_connectResponseCompleter.resume(returning: .join(joinResponse))
print("creationTime: \(joinResponse.room.creationTime)")
await _restartPingTimer()

case let .reconnect(response):
Expand Down
7 changes: 6 additions & 1 deletion Tests/LiveKitTests/RoomTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@
import XCTest

class RoomTests: XCTestCase {
func testResolveSid() async throws {
func testRoomProperties() async throws {
try await withRooms([RoomTestingOptions()]) { rooms in
// Alias to Room
let room1 = rooms[0]

// SID
let sid = try await room1.sid()
print("Room.sid(): \(String(describing: sid))")
XCTAssert(sid.stringValue.starts(with: "RM_"))

// creationTime
XCTAssert(room1.creationTime != nil)
print("Room.creationTime: \(String(describing: room1.creationTime))")
}
}

Expand Down