mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 19:11:10 +00:00
Add more logging
This commit is contained in:
1 parent
20af028cc3
commit
e5ae0c250e
3 files changed
+22
-7
No files matched your search
@@ -45,10 +45,8 @@ class InboundNearbyConnection: NearbyConnection {
|
||||
}
|
||||
|
||||
override func processReceivedFrame(frameData: Data) {
|
||||
if currentState != .receivingFiles {
|
||||
log("Received frame in state \(currentState)...")
|
||||
}
|
||||
|
||||
log("Received frame in state \(currentState)...")
|
||||
|
||||
do {
|
||||
switch currentState {
|
||||
case .initial:
|
||||
@@ -132,6 +130,7 @@ class InboundNearbyConnection: NearbyConnection {
|
||||
transferredFiles.removeValue(forKey: id)
|
||||
|
||||
if transferredFiles.isEmpty {
|
||||
log("All files received, sending disconnection frame and disconnecting.")
|
||||
try sendDisconnectionAndDisconnect()
|
||||
}
|
||||
}
|
||||
@@ -154,6 +153,7 @@ class InboundNearbyConnection: NearbyConnection {
|
||||
}
|
||||
}
|
||||
|
||||
log("Received text payload. Disconnecting...")
|
||||
try sendDisconnectionAndDisconnect()
|
||||
return true
|
||||
}
|
||||
@@ -166,6 +166,8 @@ class InboundNearbyConnection: NearbyConnection {
|
||||
fileInfo.progress?.unpublish()
|
||||
transferredFiles.removeValue(forKey: id)
|
||||
SaveFilesManager.shared.registerFileFinishedDownloading(fileInfo.destinationURL)
|
||||
|
||||
log("Received file payload. Disconnecting...")
|
||||
try sendDisconnectionAndDisconnect()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ class NearbyConnection {
|
||||
}
|
||||
|
||||
func protocolError() {
|
||||
log("Protocol error: \(String(describing: lastError))")
|
||||
disconnect()
|
||||
}
|
||||
|
||||
@@ -108,6 +109,7 @@ class NearbyConnection {
|
||||
return
|
||||
}
|
||||
if isComplete {
|
||||
log("Connection closed by peer during receiveFrameAsync")
|
||||
self.handleConnectionClosure()
|
||||
return
|
||||
}
|
||||
@@ -136,6 +138,7 @@ class NearbyConnection {
|
||||
return
|
||||
}
|
||||
if isComplete {
|
||||
log("Connection closed by peer during receiveFrameAsync")
|
||||
self.handleConnectionClosure()
|
||||
return
|
||||
}
|
||||
@@ -410,11 +413,15 @@ class NearbyConnection {
|
||||
}
|
||||
|
||||
func disconnect() {
|
||||
log("Disconnecting from connection.")
|
||||
|
||||
connection.stateUpdateHandler = nil
|
||||
connectionClosed = true
|
||||
|
||||
self.handleConnectionClosure()
|
||||
|
||||
connection.send(content: nil, isComplete: true, completion: .contentProcessed { _ in
|
||||
})
|
||||
self.handleConnectionClosure()
|
||||
connectionClosed = true
|
||||
connection.stateUpdateHandler = nil
|
||||
}
|
||||
|
||||
func sendDisconnectionAndDisconnect() throws {
|
||||
@@ -428,6 +435,8 @@ class NearbyConnection {
|
||||
} else {
|
||||
try sendFrameAsync(offlineFrame.serializedData())
|
||||
}
|
||||
|
||||
log("Sent disconnection frame during sendDisconnectionAndDisconnect")
|
||||
disconnect()
|
||||
}
|
||||
|
||||
@@ -438,6 +447,8 @@ class NearbyConnection {
|
||||
msg.messageType = .alert
|
||||
msg.messageData = try! alert.serializedData()
|
||||
sendFrameAsync(try! msg.serializedData())
|
||||
|
||||
log("Sent UKEY2 alert: \(type)")
|
||||
disconnect()
|
||||
}
|
||||
|
||||
|
||||
@@ -269,6 +269,8 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb
|
||||
|
||||
public func submitUserConsent(transferID: String, accept: Bool, storeInTemp: Bool = false) {
|
||||
guard let conn = activeConnections[transferID] else { return }
|
||||
|
||||
log("Submitting user consent for transfer, accepted: \(accept), store in temp: \(storeInTemp)")
|
||||
conn.submitUserConsent(accepted: accept, storeInTemp: storeInTemp)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user