mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 02:51:11 +00:00
Allow multiple incoming connections
This commit is contained in:
1 parent
bb1f28af0b
commit
6401c1969c
2 files changed
-19
No files matched your search
@@ -539,12 +539,6 @@ class InboundNearbyConnection: NearbyConnection {
|
||||
let acceptAutomatically = isAuthenticated || Settings.sharedInstance.automaticallyAcceptFiles
|
||||
|
||||
DispatchQueue.main.async {
|
||||
if !NearbyConnectionManager.shared.claimIncomingTransfer(id: self.id) {
|
||||
log("[InboundNearbyConnection \(self.id)] Another transfer is active. Rejecting incoming transfer.")
|
||||
self.rejectTransfer()
|
||||
return
|
||||
}
|
||||
|
||||
if acceptAutomatically {
|
||||
self.delegate?.obtainedUserConsentAutomatically(transfer: metadata, device: self.remoteDeviceInfo!, connection: self)
|
||||
self.submitUserConsent(accepted: true, trustDevice: false)
|
||||
|
||||
@@ -29,7 +29,6 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
||||
private var tcpListener: NWListener
|
||||
private var mdnsServices: [NetService] = []
|
||||
private var incomingConnections: [String: InboundNearbyConnection] = [:]
|
||||
private var activeIncomingTransferID: String?
|
||||
private var foundServices: [String: FoundServiceInfo] = [:]
|
||||
private var outboundAppDelegates: [OutboundAppDelegate] = []
|
||||
private var inboundAppDelegates: [InboundAppDelegate] = []
|
||||
@@ -341,9 +340,6 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
||||
|
||||
|
||||
func connectionWasTerminated(connection: InboundNearbyConnection, savedFiles: [URL], error: Error?) {
|
||||
if activeIncomingTransferID == connection.id {
|
||||
activeIncomingTransferID = nil
|
||||
}
|
||||
incomingConnections.removeValue(forKey: connection.id)
|
||||
|
||||
if !connection.wasUserRejected {
|
||||
@@ -486,15 +482,6 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
||||
}
|
||||
}
|
||||
|
||||
func claimIncomingTransfer(id: String) -> Bool {
|
||||
if let activeIncomingTransferID, activeIncomingTransferID != id {
|
||||
return false
|
||||
}
|
||||
activeIncomingTransferID = id
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
private func endpointID(for service: NWBrowser.Result) -> String? {
|
||||
guard case let NWEndpoint.service(name: serviceName, type: _, domain: _, interface: _) = service.endpoint else { return nil }
|
||||
guard let nameData = Data.dataFromUrlSafeBase64(serviceName) else { return nil }
|
||||
|
||||
Reference in new issue
Block a user