mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-13 00:33:28 +01:00
App builds in xcodeproj (todo widget)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
import Foundation
|
||||
import Network
|
||||
import SideKit
|
||||
import os.log
|
||||
|
||||
public protocol SideConnection: Connection {
|
||||
func __send(_ data: Data, completionHandler: @escaping (Bool, Error?) -> Void)
|
||||
@@ -74,7 +75,7 @@ public extension SideConnection {
|
||||
func receiveRequest(completionHandler: @escaping (Result<ServerRequest, ALTServerError>) -> Void) {
|
||||
let size = MemoryLayout<Int32>.size
|
||||
|
||||
print("Receiving request size from connection:", self)
|
||||
os_log("Receiving request size from connection: %@", type: .info , String(describing: self))
|
||||
receiveData(expectedSize: size) { result in
|
||||
do {
|
||||
let data = try result.get()
|
||||
@@ -87,7 +88,7 @@ public extension SideConnection {
|
||||
let data = try result.get()
|
||||
let request = try JSONDecoder().decode(ServerRequest.self, from: data)
|
||||
|
||||
print("Received request:", request)
|
||||
os_log("Received request: %@", type: .info , String(describing: request))
|
||||
completionHandler(.success(request))
|
||||
} catch {
|
||||
completionHandler(.failure(ALTServerError(error)))
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import Foundation
|
||||
import Network
|
||||
import SideKit
|
||||
import os.log
|
||||
|
||||
public protocol RequestHandler {
|
||||
func handleAnisetteDataRequest(_ request: AnisetteDataRequest, for connection: Connection, completionHandler: @escaping (Result<AnisetteDataResponse, Error>) -> Void)
|
||||
@@ -102,18 +103,18 @@ private extension ConnectionManager {
|
||||
do {
|
||||
let response = try result.get()
|
||||
connection.send(response, shouldDisconnect: true) { result in
|
||||
print("Sent response \(response) with result:", result)
|
||||
os_log("Sent response %@ with result: %@", type: .error , response.identifier, String(describing: result))
|
||||
}
|
||||
} catch {
|
||||
let response = ErrorResponse(error: ALTServerError(error))
|
||||
connection.send(response, shouldDisconnect: true) { result in
|
||||
print("Sent error response \(response) with result:", result)
|
||||
os_log("Sent error response %@ with result: %@", type: .error , response.error.localizedDescription, String(describing: result))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
connection.receiveRequest { result in
|
||||
print("Received request with result:", result)
|
||||
os_log("Received request with result: %@", type: .info, String(describing: result))
|
||||
|
||||
switch result {
|
||||
case let .failure(error): finish(Result<ErrorResponse, Error>.failure(error))
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
import SideKit
|
||||
import os.log
|
||||
|
||||
@objc private protocol XPCConnectionProxy {
|
||||
func ping(completionHandler: @escaping () -> Void)
|
||||
@@ -56,7 +57,7 @@ public class XPCConnection: NSObject, SideConnection {
|
||||
private extension XPCConnection {
|
||||
func makeProxy(errorHandler: @escaping (Error) -> Void) -> XPCConnectionProxy {
|
||||
let proxy = xpcConnection.remoteObjectProxyWithErrorHandler { error in
|
||||
print("Error messaging remote object proxy:", error)
|
||||
os_log("Error messaging remote object proxy: %@", type: .error , error.localizedDescription)
|
||||
self.error = error
|
||||
errorHandler(error)
|
||||
} as! XPCConnectionProxy
|
||||
|
||||
Reference in New Issue
Block a user