mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 02:51:11 +00:00
Always log, not just in debug
This commit is contained in:
1 parent
d055140364
commit
e43e017803
3 files changed
-20
No files matched your search
@@ -298,9 +298,7 @@ class NearbyConnection{
|
||||
try processFileChunk(frame: payloadTransfer)
|
||||
}
|
||||
}else if offlineFrame.hasV1 && offlineFrame.v1.hasType, case .keepAlive = offlineFrame.v1.type{
|
||||
#if DEBUG
|
||||
log("Sent keep-alive")
|
||||
#endif
|
||||
sendKeepAlive(ack: true)
|
||||
}else{
|
||||
log("Unhandled offline frame encrypted: \(offlineFrame)")
|
||||
|
||||
@@ -317,21 +317,15 @@ public class NearbyConnectionManager : NSObject, NetServiceDelegate, InboundNear
|
||||
}
|
||||
|
||||
private func maybeAddFoundDevice(service:NWBrowser.Result){
|
||||
#if DEBUG
|
||||
log("found service \(service)")
|
||||
#endif
|
||||
for interface in service.interfaces{
|
||||
if case .loopback=interface.type{
|
||||
#if DEBUG
|
||||
log("ignoring localhost service")
|
||||
#endif
|
||||
return
|
||||
}
|
||||
}
|
||||
guard let endpointID=endpointID(for: service) else {return}
|
||||
#if DEBUG
|
||||
log("service name is valid, endpoint ID \(endpointID)")
|
||||
#endif
|
||||
var foundService=FoundServiceInfo(service: service)
|
||||
|
||||
guard case let NWBrowser.Result.Metadata.bonjour(txtRecord)=service.metadata else {return}
|
||||
|
||||
@@ -79,9 +79,7 @@ class OutboundNearbyConnection:NearbyConnection{
|
||||
|
||||
override func processReceivedFrame(frameData: Data) {
|
||||
do{
|
||||
#if DEBUG
|
||||
log("received \(frameData), state is \(currentState)")
|
||||
#endif
|
||||
switch currentState {
|
||||
case .initial:
|
||||
protocolError()
|
||||
@@ -223,9 +221,7 @@ class OutboundNearbyConnection:NearbyConnection{
|
||||
}
|
||||
|
||||
private func processConnectionResponse(frame:Location_Nearby_Connections_OfflineFrame) throws{
|
||||
#if DEBUG
|
||||
log("connection response: \(frame)")
|
||||
#endif
|
||||
guard frame.version == .v1 else {throw NearbyError.protocolError("Unexpected offline frame version \(frame.version)")}
|
||||
guard frame.v1.type == .connectionResponse else {throw NearbyError.protocolError("Unexpected frame type \(frame.v1.type)")}
|
||||
guard frame.v1.connectionResponse.response == .accept else {throw NearbyError.protocolError("Connection was rejected by recipient")}
|
||||
@@ -305,9 +301,7 @@ class OutboundNearbyConnection:NearbyConnection{
|
||||
totalBytesToSend+=meta.size
|
||||
}
|
||||
}
|
||||
#if DEBUG
|
||||
log("sent introduction: \(introduction)")
|
||||
#endif
|
||||
try sendTransferSetupFrame(introduction)
|
||||
|
||||
currentState = .sentIntroduction
|
||||
@@ -354,9 +348,7 @@ class OutboundNearbyConnection:NearbyConnection{
|
||||
try currentTransfer?.handle?.close()
|
||||
}
|
||||
if queue.isEmpty{
|
||||
#if DEBUG
|
||||
log("Disconnecting because all files have been transferred")
|
||||
#endif
|
||||
try sendDisconnectionAndDisconnect()
|
||||
delegate?.outboundConnectionTransferFinished(connection: self)
|
||||
return
|
||||
@@ -398,9 +390,7 @@ class OutboundNearbyConnection:NearbyConnection{
|
||||
self.protocolError()
|
||||
}
|
||||
})
|
||||
#if DEBUG
|
||||
log("sent file chunk, current transfer: \(String(describing: currentTransfer))")
|
||||
#endif
|
||||
totalBytesSent+=Int64(fileBuffer.count)
|
||||
delegate?.outboundConnection(connection: self, transferProgress: Double(totalBytesSent)/Double(totalBytesToSend))
|
||||
|
||||
@@ -421,9 +411,7 @@ class OutboundNearbyConnection:NearbyConnection{
|
||||
wrapper.v1.type = .payloadTransfer
|
||||
wrapper.v1.payloadTransfer=transfer
|
||||
try encryptAndSendOfflineFrame(wrapper)
|
||||
#if DEBUG
|
||||
log("sent EOF, current transfer: \(String(describing: currentTransfer))")
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user