Skip to content

Commit 9c792fd

Browse files
committed
JSON keys
1 parent 709949f commit 9c792fd

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

Sources/LiveKit/Auth/ConnectionCredentials.swift

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ public enum ConnectionCredentials {
3737
/// - SeeAlso: [Room Configuration Documentation](https://docs.livekit.io/home/get-started/authentication/#room-configuration) for more info.
3838
let roomConfiguration: RoomConfiguration?
3939

40+
// enum CodingKeys: String, CodingKey {
41+
// case roomName = "room_name"
42+
// case participantName = "participant_name"
43+
// case participantIdentity = "participant_identity"
44+
// case participantMetadata = "participant_metadata"
45+
// case participantAttributes = "participant_attributes"
46+
// case roomConfiguration = "room_configuration"
47+
// }
48+
4049
public init(
4150
roomName: String? = nil,
4251
participantName: String? = nil,
@@ -57,12 +66,17 @@ public enum ConnectionCredentials {
5766
/// Response containing the credentials needed to connect to a room.
5867
public struct Response: Decodable, Sendable {
5968
/// The WebSocket URL for the LiveKit server.
60-
let serverUrl: URL
69+
let serverURL: URL
6170
/// The JWT token containing participant permissions and metadata.
6271
let participantToken: String
6372

64-
public init(serverUrl: URL, participantToken: String) {
65-
self.serverUrl = serverUrl
73+
enum CodingKeys: String, CodingKey {
74+
case serverURL = "serverUrl"
75+
case participantToken
76+
}
77+
78+
public init(serverURL: URL, participantToken: String) {
79+
self.serverURL = serverURL
6680
self.participantToken = participantToken
6781
}
6882
}
@@ -117,11 +131,11 @@ public extension TokenServer {
117131
let (data, response) = try await URLSession.shared.data(for: urlRequest)
118132

119133
guard let httpResponse = response as? HTTPURLResponse else {
120-
throw LiveKitError(.network, message: "Error generating token from sandbox token server, no response")
134+
throw LiveKitError(.network, message: "Error generating token from the token server, no response")
121135
}
122136

123137
guard (200 ... 299).contains(httpResponse.statusCode) else {
124-
throw LiveKitError(.network, message: "Error generating token from sandbox token server, received \(httpResponse)")
138+
throw LiveKitError(.network, message: "Error generating token from the token server, received \(httpResponse)")
125139
}
126140

127141
return try JSONDecoder().decode(ConnectionCredentials.Response.self, from: data)

Sources/LiveKit/Core/Room.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ public class Room: NSObject, @unchecked Sendable, ObservableObject, Loggable {
414414
roomOptions: RoomOptions? = nil) async throws
415415
{
416416
let credentials = try await credentialsProvider.fetch(credentialsOptions)
417-
try await connect(url: credentials.serverUrl.absoluteString, token: credentials.participantToken, connectOptions: connectOptions, roomOptions: roomOptions)
417+
try await connect(url: credentials.serverURL.absoluteString, token: credentials.participantToken, connectOptions: connectOptions, roomOptions: roomOptions)
418418
}
419419

420420
@objc

0 commit comments

Comments
 (0)