mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-21 22:05:59 +00:00
Refactoring
This commit is contained in:
1 parent
f4a21d3f0a
commit
9f2af19adb
1 file changed
+6
-11
@@ -19,8 +19,8 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
|||||||
private var foundServices: [String: FoundServiceInfo] = [:]
|
private var foundServices: [String: FoundServiceInfo] = [:]
|
||||||
private var shareExtensionDelegates: [ShareExtensionDelegate] = []
|
private var shareExtensionDelegates: [ShareExtensionDelegate] = []
|
||||||
private var outgoingTransfers: [String: OutgoingTransferInfo] = [:]
|
private var outgoingTransfers: [String: OutgoingTransferInfo] = [:]
|
||||||
private var discoveryRefCount = 0
|
private var startedDeviceDiscovery = false
|
||||||
private var browsers: [NWBrowser] = []
|
private var browsers: [NWBrowser] = []
|
||||||
private let serviceTypes = ["_FC9F5ED42C8A._tcp."]
|
private let serviceTypes = ["_FC9F5ED42C8A._tcp."]
|
||||||
|
|
||||||
public let endpointID: [UInt8] = generateEndpointID()
|
public let endpointID: [UInt8] = generateEndpointID()
|
||||||
@@ -129,9 +129,9 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
|||||||
|
|
||||||
|
|
||||||
public func startDeviceDiscovery() {
|
public func startDeviceDiscovery() {
|
||||||
log("Device discovery requested.")
|
|
||||||
|
if !startedDeviceDiscovery {
|
||||||
if discoveryRefCount == 0 {
|
startedDeviceDiscovery = true
|
||||||
foundServices.removeAll()
|
foundServices.removeAll()
|
||||||
|
|
||||||
log("Starting device discovery")
|
log("Starting device discovery")
|
||||||
@@ -158,16 +158,11 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
discoveryRefCount += 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public func stopDeviceDiscovery() {
|
public func stopDeviceDiscovery() {
|
||||||
discoveryRefCount -= 1
|
if startedDeviceDiscovery {
|
||||||
assert(discoveryRefCount >= 0)
|
|
||||||
|
|
||||||
if discoveryRefCount == 0 {
|
|
||||||
for browser in browsers {
|
for browser in browsers {
|
||||||
browser.cancel()
|
browser.cancel()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user