File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -38,14 +38,24 @@ open class PusherConnection: NSObject {
3838
3939 open lazy var reachability : Reachability ? = {
4040 let reachability = Reachability . init ( )
41- reachability? . whenReachable = { [ unowned self] reachability in
42- self . delegate? . debugLog ? ( message: " [PUSHER DEBUG] Network reachable " )
43- if self . connectionState == . disconnected || self . connectionState == . reconnectingWhenNetworkBecomesReachable {
44- self . attemptReconnect ( )
41+ reachability? . whenReachable = { [ weak self] reachability in
42+ guard self != nil else {
43+ print ( " Your Pusher instance has probably become deallocated. See https://github.com/pusher/pusher-websocket-swift/issues/109 for more information " )
44+ return
45+ }
46+
47+ self !. delegate? . debugLog ? ( message: " [PUSHER DEBUG] Network reachable " )
48+ if self !. connectionState == . disconnected || self !. connectionState == . reconnectingWhenNetworkBecomesReachable {
49+ self !. attemptReconnect ( )
4550 }
4651 }
47- reachability? . whenUnreachable = { [ unowned self] reachability in
48- self . delegate? . debugLog ? ( message: " [PUSHER DEBUG] Network unreachable " )
52+ reachability? . whenUnreachable = { [ weak self] reachability in
53+ guard self != nil else {
54+ print ( " Your Pusher instance has probably become deallocated. See https://github.com/pusher/pusher-websocket-swift/issues/109 for more information " )
55+ return
56+ }
57+
58+ self !. delegate? . debugLog ? ( message: " [PUSHER DEBUG] Network unreachable " )
4959 }
5060 return reachability
5161 } ( )
You can’t perform that action at this time.
0 commit comments