mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 02:51:11 +00:00
Add check if connection already closed
This commit is contained in:
1 parent
e5ae0c250e
commit
46997ab9fc
1 file changed
+17
-12
@@ -52,20 +52,25 @@ class NearbyConnection {
|
||||
|
||||
func start() {
|
||||
connection.stateUpdateHandler = { state in
|
||||
if case .ready = state {
|
||||
self.connectionReady()
|
||||
self.receiveFrameAsync()
|
||||
} else if case let .failed(err) = state {
|
||||
self.lastError = err
|
||||
log("Error opening socket: \(err)")
|
||||
|
||||
if err == .posix(.ENOTCONN) {
|
||||
ConnectionFailureTracker.shared.recordFailure {
|
||||
NearbyConnectionManager.shared.mainAppDelegate?.showFirewallAlert()
|
||||
if !self.connectionClosed {
|
||||
if case .ready = state {
|
||||
self.connectionReady()
|
||||
self.receiveFrameAsync()
|
||||
} else if case let .failed(err) = state {
|
||||
self.lastError = err
|
||||
log("Error opening socket: \(err)")
|
||||
|
||||
if err == .posix(.ENOTCONN) {
|
||||
ConnectionFailureTracker.shared.recordFailure {
|
||||
NearbyConnectionManager.shared.mainAppDelegate?.showFirewallAlert()
|
||||
}
|
||||
}
|
||||
|
||||
self.handleConnectionClosure()
|
||||
}
|
||||
|
||||
self.handleConnectionClosure()
|
||||
}
|
||||
else {
|
||||
log("Connection already closed, ignoring state update: \(state)")
|
||||
}
|
||||
}
|
||||
// connection.start(queue: .global(qos: .utility))
|
||||
|
||||
Reference in new issue
Block a user