syntax fix

This commit is contained in:
Mike Renoir 2023-03-09 17:00:57 +04:00
parent 39fcea4a85
commit 589d9f7155

View File

@ -231,15 +231,23 @@ final class NetworkFrameworkTcpConnectionInterface: NSObject, MTTcpConnectionInt
self.processReadRequests()
} else {
connection.receive(minimumIncompleteLength: requestChunkLength, maximumLength: requestChunkLength, completion: { [weak self] data, context, isComplete, error in
guard let self = self, let currentReadRequest = self.currentReadRequest else {
self?.readWithBytes(data: data, isComplete: isComplete, error: error)
})
}
}
private func readWithBytes(data: Data?, isComplete: Bool, error: Error?) {
guard let currentReadRequest = self.currentReadRequest else {
return
}
if let data = data {
self.networkUsageManager?.addIncomingBytes(UInt(data.count), interface: self.currentInterfaceIsWifi ? MTNetworkUsageManagerInterfaceOther : MTNetworkUsageManagerInterfaceWWAN)
if data.count != 0 && data.count <= currentReadRequest.request.length - currentReadRequest.readyLength {
currentReadRequest.data.withUnsafeMutableBytes { currentBuffer in
guard let currentBytes = currentBuffer.assumingMemoryBound(to: UInt8.self).baseAddress else {
guard let currentBytes = currentBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else {
return
}
data.copyBytes(to: currentBytes.advanced(by: currentReadRequest.readyLength), count: data.count)
@ -266,8 +274,7 @@ final class NetworkFrameworkTcpConnectionInterface: NSObject, MTTcpConnectionInt
} else {
self.cancelWithError(error: error)
}
})
}
}
private func cancelWithError(error: Error?) {