Replace local code with updated Roxas and SideKit

Signed-off-by: Joseph Mattello <mail@joemattiello.com>
This commit is contained in:
Joseph Mattello
2023-02-25 01:37:52 -05:00
committed by Joe Mattiello
parent 4e84dc4cc8
commit f270ecc537
14 changed files with 124 additions and 1200 deletions

View File

@@ -8,17 +8,19 @@
import Foundation
import Network
import SideKit
public extension Connection
{
func send(_ data: Data, completionHandler: @escaping (Result<Void, ALTServerError>) -> Void)
{
self.__send(data) { (success, error) in
let result = Result(success, error).mapError { (error) -> ALTServerError in
guard let nwError = error as? NWError else { return ALTServerError(error) }
return ALTServerError(.lostConnection, underlyingError: nwError)
let result = Result(success, error).mapError { (failure :Error) -> ALTServerError in
guard let nwError = failure as? NWError else { return ALTServerError.init(failure) }
return ALTServerError.lostConnection(underlyingError: nwError)
}
completionHandler(result)
}
}
@@ -26,9 +28,9 @@ public extension Connection
func receiveData(expectedSize: Int, completionHandler: @escaping (Result<Data, ALTServerError>) -> Void)
{
self.__receiveData(expectedSize: expectedSize) { (data, error) in
let result = Result(data, error).mapError { (error) -> ALTServerError in
guard let nwError = error as? NWError else { return ALTServerError(error) }
return ALTServerError(.lostConnection, underlyingError: nwError)
let result = Result(data, error).mapError { (failure :Error) -> ALTServerError in
guard let nwError = failure as? NWError else { return ALTServerError.init(failure) }
return ALTServerError.lostConnection(underlyingError: nwError)
}
completionHandler(result)
@@ -72,7 +74,7 @@ public extension Connection
}
catch
{
finish(.failure(.init(.invalidResponse, underlyingError: error)))
finish(.failure(.invalidResponse(underlyingError: error)))
}
}