Skip to content

Commit

Permalink
Run web socket pings and reconnections on ping handling as detached t…
Browse files Browse the repository at this point in the history
…asks
  • Loading branch information
claucambra committed Jul 9, 2024
1 parent 1356442 commit c2b947a
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,15 @@ public class RemoteChangeObserver: NSObject, NKCommonDelegate, URLSessionWebSock
)
self.webSocketPingFailCount += 1
if self.webSocketPingFailCount > self.webSocketPingFailLimit {
self.reconnectWebSocket()
Task.detached(priority: .medium) { self.reconnectWebSocket() }
} else {
self.pingWebSocket()
Task.detached(priority: .background) { self.pingWebSocket() }
}
return
}

// TODO: Stop on auth change
Task {
Task.detached(priority: .background) {
do {
try await Task.sleep(nanoseconds: self.webSocketPingIntervalNanoseconds)
} catch let error {
Expand Down

0 comments on commit c2b947a

Please sign in to comment.