[AltKit] Gracefully fails if no data is received over network connection

This commit is contained in:
Riley Testut
2020-06-05 15:43:05 -07:00
parent 0be1be5769
commit bef3eb3964

View File

@@ -28,6 +28,10 @@ public class NetworkConnection: NSObject, Connection
public func __receiveData(expectedSize: Int, completionHandler: @escaping (Data?, Error?) -> Void)
{
self.nwConnection.receive(minimumIncompleteLength: expectedSize, maximumLength: expectedSize) { (data, context, isComplete, error) in
guard data != nil || error != nil else {
return completionHandler(nil, ALTServerError(.lostConnection))
}
completionHandler(data, error)
}
}