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