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
2 changes: 1 addition & 1 deletion Sources/Realtime/RealtimeChannelV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public final class RealtimeChannelV2: Sendable, RealtimeChannelProtocol {
)
Task {
await unsubscribe()
await subscribe()
try? await subscribeWithError()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change, but it just fixes a deprecation warning

}
}

Expand Down
10 changes: 5 additions & 5 deletions Sources/Realtime/RealtimeClientV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public final class RealtimeClientV2: Sendable, RealtimeClientProtocol {
let wsTransport: WebSocketTransport
let mutableState = LockIsolated(MutableState())
let http: any HTTPClientType
let apikey: String?
let apikey: String

var conn: (any WebSocket)? {
mutableState.conn
Expand Down Expand Up @@ -157,13 +157,13 @@ public final class RealtimeClientV2: Sendable, RealtimeClientProtocol {
self.options = options
self.wsTransport = wsTransport
self.http = http
apikey = options.apikey

precondition(options.apikey != nil, "API key is required to connect to Realtime")
apikey = options.apikey!

mutableState.withValue { [options] in
if let accessToken = options.headers[.authorization]?.split(separator: " ").last {
$0.accessToken = String(accessToken)
} else {
$0.accessToken = options.apikey
}
}
}
Expand Down Expand Up @@ -360,7 +360,7 @@ public final class RealtimeClientV2: Sendable, RealtimeClientProtocol {
private func rejoinChannels() {
Task {
for channel in channels.values {
await channel.subscribe()
try? await channel.subscribeWithError()
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/RealtimeTests/RealtimeChannelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class RealtimeChannelTests: XCTestCase {
),
socket: RealtimeClientV2(
url: URL(string: "https://localhost:54321/realtime/v1")!,
options: RealtimeClientOptions()
options: RealtimeClientOptions(headers: ["apikey": "test-key"])
),
logger: nil
)
Expand Down Expand Up @@ -161,8 +161,8 @@ final class RealtimeChannelTests: XCTestCase {
XCTAssertTrue(channel.callbackManager.callbacks.contains(where: { $0.isPresence }))

// Start subscription process
let subscribeTask = Task {
await channel.subscribe()
Task {
try? await channel.subscribeWithError()
}

// Wait for the join message to be sent
Expand Down
Loading