mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 02:51:11 +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 shareExtensionDelegates: [ShareExtensionDelegate] = []
|
||||
private var outgoingTransfers: [String: OutgoingTransferInfo] = [:]
|
||||
private var discoveryRefCount = 0
|
||||
private var browsers: [NWBrowser] = []
|
||||
private var startedDeviceDiscovery = false
|
||||
private var browsers: [NWBrowser] = []
|
||||
private let serviceTypes = ["_FC9F5ED42C8A._tcp."]
|
||||
|
||||
public let endpointID: [UInt8] = generateEndpointID()
|
||||
@@ -129,9 +129,9 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
||||
|
||||
|
||||
public func startDeviceDiscovery() {
|
||||
log("Device discovery requested.")
|
||||
|
||||
if discoveryRefCount == 0 {
|
||||
|
||||
if !startedDeviceDiscovery {
|
||||
startedDeviceDiscovery = true
|
||||
foundServices.removeAll()
|
||||
|
||||
log("Starting device discovery")
|
||||
@@ -158,16 +158,11 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
discoveryRefCount += 1
|
||||
}
|
||||
|
||||
|
||||
public func stopDeviceDiscovery() {
|
||||
discoveryRefCount -= 1
|
||||
assert(discoveryRefCount >= 0)
|
||||
|
||||
if discoveryRefCount == 0 {
|
||||
if startedDeviceDiscovery {
|
||||
for browser in browsers {
|
||||
browser.cancel()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user