Skip to content

Commit

Permalink
Merge pull request #8 from simla-tech/pingDispatchWorkItem_can_cancel
Browse files Browse the repository at this point in the history
add conditions for before cancel pingDispatchWorkItem
  • Loading branch information
UriyDevyataev authored Oct 8, 2024
2 parents 6239331 + dfd72c8 commit 11b350a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/Network/SubscriptionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ public class SubscriptionManager: NSObject {
break

case .completed:
self.pingDispatchWorkItem?.cancel()
if let workItem = self.pingDispatchWorkItem, !workItem.isCancelled {
workItem.cancel()
}
let closeCode = (self.webSocketRequest?.lastTask as? URLSessionWebSocketTask)?.closeCode ?? .invalid
let error = self.webSocketRequest?.error?.underlyingError ?? self.webSocketRequest?.error
var reason: SocketDisconnectReason = .code(closeCode)
Expand Down

0 comments on commit 11b350a

Please sign in to comment.