diff --git a/Frameworks/Bindings.txt b/Frameworks/Bindings.txt index 40b4da03e422b4e46fd0e7c38e7cae297ede0ce5..d8cc181f5ce12abf112fab8bfc32f02fac3c5a04 100644 --- a/Frameworks/Bindings.txt +++ b/Frameworks/Bindings.txt @@ -1,4 +1,4 @@ -https://git.xx.network/elixxir/client/-/commit/36530a48ba7ad35fc8b7b9bfc304a791721ff0c7 +https://git.xx.network/elixxir/client/-/commit/30a957691e23a914e297304022207e6f6446b699 go version go1.17.13 darwin/arm64 Xcode 14.1 Build version 14B47b gomobile bind target: ios,iossimulator,macos diff --git a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Bindings b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Bindings index f1ed7ad63cd83061d042ad0c253171ad30010b54..e00697e95ad74577faf9268732278371a3f5b6cd 100644 Binary files a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Bindings and b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Bindings differ diff --git a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Headers/Bindings.objc.h b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Headers/Bindings.objc.h index bea26d708bde197cff85fdabafa9af41b0433bff..8c041875c58f46b06bf6e9517453a28f8ffdbdda 100644 --- a/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Headers/Bindings.objc.h +++ b/Frameworks/Bindings.xcframework/ios-arm64/Bindings.framework/Versions/A/Headers/Bindings.objc.h @@ -33,6 +33,7 @@ @class BindingsGroupChatMessage; @class BindingsGroupReport; @class BindingsGroupSendReport; +@class BindingsIsReadyInfo; @class BindingsMessage; @class BindingsNodeRegistrationReport; @class BindingsNotificationReport; @@ -846,6 +847,16 @@ the bindings Cmix interface. health changes. Returns a registration ID that can be used to unregister. */ - (int64_t)addHealthCallback:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +/** + * ChangeNumberOfNodeRegistrations changes the number of parallel node +registrations up to the initialized maximum. + +Parameters: + - toRun - The number of parallel node registrations. + - timeoutMS - The timeout, in milliseconds, to wait when changing node + registrations before failing. + */ +- (BOOL)changeNumberOfNodeRegistrations:(long)toRun timeoutMS:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** * Connect performs auth key negotiation with the given recipient and returns a Connection object for the newly created partner.Manager. @@ -904,16 +915,24 @@ Due to the handling of comms on iOS, where the OS can block indefinitely, it may not enter the stopped state appropriately. This can be used instead. */ - (BOOL)hasRunningProcessies; -/** - * IncreaseParallelNodeRegistration increases the number of parallel node -registrations by num - */ -- (BOOL)increaseParallelNodeRegistration:(long)num error:(NSError* _Nullable* _Nullable)error; /** * IsHealthy returns true if the network is read to be in a healthy state where messages can be sent. */ - (BOOL)isHealthy; +/** + * IsReady returns true if at least percentReady of node registrations has +completed. If not all have completed, then it returns false and howClose will +be a percent (0-1) of node registrations completed. + +Parameters: + - percentReady - The percentage of nodes required to be registered with to + be ready. This is a number between 0 and 1. + +Returns: + - JSON of [IsReadyInfo]. + */ +- (NSData* _Nullable)isReady:(double)percentReady error:(NSError* _Nullable* _Nullable)error; /** * MakeLegacyReceptionIdentity generates the legacy identity for receiving messages. As with all legacy calls, this should primarily be used @@ -933,6 +952,15 @@ status with the following values: Stopping - 3000 */ - (long)networkFollowerStatus; +/** + * PauseNodeRegistrations stops all node registrations and returns a function to +resume them. + +Parameters: + - timeoutMS - The timeout, in milliseconds, to wait when stopping threads + before failing. + */ +- (BOOL)pauseNodeRegistrations:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** * ReadyToSend determines if the network is ready to send messages on. It returns true if the network is healthy and if the client has registered with @@ -1881,6 +1909,26 @@ Example GroupSendReport JSON: - (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; @end +/** + * IsReadyInfo contains information on if the network is ready and how close it +is to being ready. + +Example JSON: + { + "IsReady": true, + "HowClose": 0.534 + } + */ +@interface BindingsIsReadyInfo : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) BOOL isReady; +@property (nonatomic) double howClose; +@end + /** * Message is the bindings' representation of a receive.Message. diff --git a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Bindings b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Bindings index 3ba9c1a2c5f7403f32f8281bf5e3bb673242fefe..ba354817f484d250be71b34f45096f35f0f2f11a 100644 Binary files a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Bindings and b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Bindings differ diff --git a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Headers/Bindings.objc.h b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Headers/Bindings.objc.h index bea26d708bde197cff85fdabafa9af41b0433bff..8c041875c58f46b06bf6e9517453a28f8ffdbdda 100644 --- a/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Headers/Bindings.objc.h +++ b/Frameworks/Bindings.xcframework/ios-arm64_x86_64-simulator/Bindings.framework/Versions/A/Headers/Bindings.objc.h @@ -33,6 +33,7 @@ @class BindingsGroupChatMessage; @class BindingsGroupReport; @class BindingsGroupSendReport; +@class BindingsIsReadyInfo; @class BindingsMessage; @class BindingsNodeRegistrationReport; @class BindingsNotificationReport; @@ -846,6 +847,16 @@ the bindings Cmix interface. health changes. Returns a registration ID that can be used to unregister. */ - (int64_t)addHealthCallback:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +/** + * ChangeNumberOfNodeRegistrations changes the number of parallel node +registrations up to the initialized maximum. + +Parameters: + - toRun - The number of parallel node registrations. + - timeoutMS - The timeout, in milliseconds, to wait when changing node + registrations before failing. + */ +- (BOOL)changeNumberOfNodeRegistrations:(long)toRun timeoutMS:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** * Connect performs auth key negotiation with the given recipient and returns a Connection object for the newly created partner.Manager. @@ -904,16 +915,24 @@ Due to the handling of comms on iOS, where the OS can block indefinitely, it may not enter the stopped state appropriately. This can be used instead. */ - (BOOL)hasRunningProcessies; -/** - * IncreaseParallelNodeRegistration increases the number of parallel node -registrations by num - */ -- (BOOL)increaseParallelNodeRegistration:(long)num error:(NSError* _Nullable* _Nullable)error; /** * IsHealthy returns true if the network is read to be in a healthy state where messages can be sent. */ - (BOOL)isHealthy; +/** + * IsReady returns true if at least percentReady of node registrations has +completed. If not all have completed, then it returns false and howClose will +be a percent (0-1) of node registrations completed. + +Parameters: + - percentReady - The percentage of nodes required to be registered with to + be ready. This is a number between 0 and 1. + +Returns: + - JSON of [IsReadyInfo]. + */ +- (NSData* _Nullable)isReady:(double)percentReady error:(NSError* _Nullable* _Nullable)error; /** * MakeLegacyReceptionIdentity generates the legacy identity for receiving messages. As with all legacy calls, this should primarily be used @@ -933,6 +952,15 @@ status with the following values: Stopping - 3000 */ - (long)networkFollowerStatus; +/** + * PauseNodeRegistrations stops all node registrations and returns a function to +resume them. + +Parameters: + - timeoutMS - The timeout, in milliseconds, to wait when stopping threads + before failing. + */ +- (BOOL)pauseNodeRegistrations:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** * ReadyToSend determines if the network is ready to send messages on. It returns true if the network is healthy and if the client has registered with @@ -1881,6 +1909,26 @@ Example GroupSendReport JSON: - (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; @end +/** + * IsReadyInfo contains information on if the network is ready and how close it +is to being ready. + +Example JSON: + { + "IsReady": true, + "HowClose": 0.534 + } + */ +@interface BindingsIsReadyInfo : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) BOOL isReady; +@property (nonatomic) double howClose; +@end + /** * Message is the bindings' representation of a receive.Message. diff --git a/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Bindings b/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Bindings index a3d439ca64fe3c33da27cacbff34d1d67683a8a2..3b8286b7b0b172479a229e8bb3360cee091682c8 100644 Binary files a/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Bindings and b/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Bindings differ diff --git a/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Headers/Bindings.objc.h b/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Headers/Bindings.objc.h index bea26d708bde197cff85fdabafa9af41b0433bff..8c041875c58f46b06bf6e9517453a28f8ffdbdda 100644 --- a/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Headers/Bindings.objc.h +++ b/Frameworks/Bindings.xcframework/macos-arm64_x86_64/Bindings.framework/Versions/A/Headers/Bindings.objc.h @@ -33,6 +33,7 @@ @class BindingsGroupChatMessage; @class BindingsGroupReport; @class BindingsGroupSendReport; +@class BindingsIsReadyInfo; @class BindingsMessage; @class BindingsNodeRegistrationReport; @class BindingsNotificationReport; @@ -846,6 +847,16 @@ the bindings Cmix interface. health changes. Returns a registration ID that can be used to unregister. */ - (int64_t)addHealthCallback:(id<BindingsNetworkHealthCallback> _Nullable)nhc; +/** + * ChangeNumberOfNodeRegistrations changes the number of parallel node +registrations up to the initialized maximum. + +Parameters: + - toRun - The number of parallel node registrations. + - timeoutMS - The timeout, in milliseconds, to wait when changing node + registrations before failing. + */ +- (BOOL)changeNumberOfNodeRegistrations:(long)toRun timeoutMS:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** * Connect performs auth key negotiation with the given recipient and returns a Connection object for the newly created partner.Manager. @@ -904,16 +915,24 @@ Due to the handling of comms on iOS, where the OS can block indefinitely, it may not enter the stopped state appropriately. This can be used instead. */ - (BOOL)hasRunningProcessies; -/** - * IncreaseParallelNodeRegistration increases the number of parallel node -registrations by num - */ -- (BOOL)increaseParallelNodeRegistration:(long)num error:(NSError* _Nullable* _Nullable)error; /** * IsHealthy returns true if the network is read to be in a healthy state where messages can be sent. */ - (BOOL)isHealthy; +/** + * IsReady returns true if at least percentReady of node registrations has +completed. If not all have completed, then it returns false and howClose will +be a percent (0-1) of node registrations completed. + +Parameters: + - percentReady - The percentage of nodes required to be registered with to + be ready. This is a number between 0 and 1. + +Returns: + - JSON of [IsReadyInfo]. + */ +- (NSData* _Nullable)isReady:(double)percentReady error:(NSError* _Nullable* _Nullable)error; /** * MakeLegacyReceptionIdentity generates the legacy identity for receiving messages. As with all legacy calls, this should primarily be used @@ -933,6 +952,15 @@ status with the following values: Stopping - 3000 */ - (long)networkFollowerStatus; +/** + * PauseNodeRegistrations stops all node registrations and returns a function to +resume them. + +Parameters: + - timeoutMS - The timeout, in milliseconds, to wait when stopping threads + before failing. + */ +- (BOOL)pauseNodeRegistrations:(long)timeoutMS error:(NSError* _Nullable* _Nullable)error; /** * ReadyToSend determines if the network is ready to send messages on. It returns true if the network is healthy and if the client has registered with @@ -1881,6 +1909,26 @@ Example GroupSendReport JSON: - (NSData* _Nullable)marshal:(NSError* _Nullable* _Nullable)error; @end +/** + * IsReadyInfo contains information on if the network is ready and how close it +is to being ready. + +Example JSON: + { + "IsReady": true, + "HowClose": 0.534 + } + */ +@interface BindingsIsReadyInfo : NSObject <goSeqRefInterface> { +} +@property(strong, readonly) _Nonnull id _ref; + +- (nonnull instancetype)initWithRef:(_Nonnull id)ref; +- (nonnull instancetype)init; +@property (nonatomic) BOOL isReady; +@property (nonatomic) double howClose; +@end + /** * Message is the bindings' representation of a receive.Message. diff --git a/Sources/XXClient/CMix/CMix.swift b/Sources/XXClient/CMix/CMix.swift index b630dc44d6a66187906ba7fe957221d2885cc530..4571f0dbf1017fcb8ee7366439add0a7e8b752f4 100644 --- a/Sources/XXClient/CMix/CMix.swift +++ b/Sources/XXClient/CMix/CMix.swift @@ -5,10 +5,12 @@ public struct CMix { public var getReceptionRegistrationValidationSignature: CMixGetReceptionRegistrationValidationSignature public var makeReceptionIdentity: CMixMakeReceptionIdentity public var isHealthy: CMixIsHealthy + public var isReady: CMixIsReady public var getNodeRegistrationStatus: CMixGetNodeRegistrationStatus + public var changeNumberOfNodeRegistrations: CMixChangeNumberOfNodeRegistrations + public var pauseNodeRegistrations: CMixPauseNodeRegistrations public var hasRunningProcesses: CMixHasRunningProcesses public var getRunningProcesses: CMixGetRunningProcesses - public var increaseParallelNodeRegistration: CMixIncreaseParallelNodeRegistration public var networkFollowerStatus: CMixNetworkFollowerStatus public var startNetworkFollower: CMixStartNetworkFollower public var stopNetworkFollower: CMixStopNetworkFollower @@ -26,10 +28,12 @@ extension CMix { getReceptionRegistrationValidationSignature: .live(bindingsCMix), makeReceptionIdentity: .live(bindingsCMix), isHealthy: .live(bindingsCMix), + isReady: .live(bindingsCMix), getNodeRegistrationStatus: .live(bindingsCMix), + changeNumberOfNodeRegistrations: .live(bindingsCMix), + pauseNodeRegistrations: .live(bindingsCMix), hasRunningProcesses: .live(bindingsCMix), getRunningProcesses: .live(bindingsCMix), - increaseParallelNodeRegistration: .live(bindingsCMix), networkFollowerStatus: .live(bindingsCMix), startNetworkFollower: .live(bindingsCMix), stopNetworkFollower: .live(bindingsCMix), @@ -48,10 +52,12 @@ extension CMix { getReceptionRegistrationValidationSignature: .unimplemented, makeReceptionIdentity: .unimplemented, isHealthy: .unimplemented, + isReady: .unimplemented, getNodeRegistrationStatus: .unimplemented, + changeNumberOfNodeRegistrations: .unimplemented, + pauseNodeRegistrations: .unimplemented, hasRunningProcesses: .unimplemented, getRunningProcesses: .unimplemented, - increaseParallelNodeRegistration: .unimplemented, networkFollowerStatus: .unimplemented, startNetworkFollower: .unimplemented, stopNetworkFollower: .unimplemented, diff --git a/Sources/XXClient/CMix/Functions/CMixChangeNumberOfNodeRegistrations.swift b/Sources/XXClient/CMix/Functions/CMixChangeNumberOfNodeRegistrations.swift new file mode 100644 index 0000000000000000000000000000000000000000..530ff497b930570acc45ae57c840a208fd628cc7 --- /dev/null +++ b/Sources/XXClient/CMix/Functions/CMixChangeNumberOfNodeRegistrations.swift @@ -0,0 +1,24 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixChangeNumberOfNodeRegistrations { + public var run: (Int, Int) throws -> Void + + public func callAsFunction(to number: Int, timeoutMS: Int) throws { + try run(number, timeoutMS) + } +} + +extension CMixChangeNumberOfNodeRegistrations { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixChangeNumberOfNodeRegistrations { + CMixChangeNumberOfNodeRegistrations( + run: bindingsCMix.changeNumber(ofNodeRegistrations:timeoutMS:) + ) + } +} + +extension CMixChangeNumberOfNodeRegistrations { + public static let unimplemented = CMixChangeNumberOfNodeRegistrations( + run: XCTestDynamicOverlay.unimplemented("\(Self.self)") + ) +} diff --git a/Sources/XXClient/CMix/Functions/CMixIncreaseParallelNodeRegistration.swift b/Sources/XXClient/CMix/Functions/CMixIncreaseParallelNodeRegistration.swift deleted file mode 100644 index 0a438c703bfed64d9f5c939db1d817a2196c2c8e..0000000000000000000000000000000000000000 --- a/Sources/XXClient/CMix/Functions/CMixIncreaseParallelNodeRegistration.swift +++ /dev/null @@ -1,24 +0,0 @@ -import Bindings -import XCTestDynamicOverlay - -public struct CMixIncreaseParallelNodeRegistration { - public var run: (Int) throws -> Void - - public func callAsFunction(num: Int) throws { - try run(num) - } -} - -extension CMixIncreaseParallelNodeRegistration { - public static func live(_ bindingsCMix: BindingsCmix) -> CMixIncreaseParallelNodeRegistration { - CMixIncreaseParallelNodeRegistration( - run: bindingsCMix.increaseParallelNodeRegistration - ) - } -} - -extension CMixIncreaseParallelNodeRegistration { - public static let unimplemented = CMixIncreaseParallelNodeRegistration( - run: XCTestDynamicOverlay.unimplemented("\(Self.self)") - ) -} diff --git a/Sources/XXClient/CMix/Functions/CMixIsReady.swift b/Sources/XXClient/CMix/Functions/CMixIsReady.swift new file mode 100644 index 0000000000000000000000000000000000000000..14e70e42e004e76fd7e7e0cb31c7da4b1e3090c0 --- /dev/null +++ b/Sources/XXClient/CMix/Functions/CMixIsReady.swift @@ -0,0 +1,24 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixIsReady { + public var run: (Double) throws -> IsReadyInfo + + public func callAsFunction(percent: Double) throws -> IsReadyInfo { + try run(percent) + } +} + +extension CMixIsReady { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixIsReady { + CMixIsReady { percent in + try IsReadyInfo.decode(try bindingsCMix.isReady(percent)) + } + } +} + +extension CMixIsReady { + public static let unimplemented = CMixIsReady( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/XXClient/CMix/Functions/CMixPauseNodeRegistrations.swift b/Sources/XXClient/CMix/Functions/CMixPauseNodeRegistrations.swift new file mode 100644 index 0000000000000000000000000000000000000000..59772c06383654f33296c712a31bf65241917971 --- /dev/null +++ b/Sources/XXClient/CMix/Functions/CMixPauseNodeRegistrations.swift @@ -0,0 +1,24 @@ +import Bindings +import XCTestDynamicOverlay + +public struct CMixPauseNodeRegistrations { + public var run: (Int) throws -> Void + + public func callAsFunction(timeoutMS: Int) throws -> Void { + try run(timeoutMS) + } +} + +extension CMixPauseNodeRegistrations { + public static func live(_ bindingsCMix: BindingsCmix) -> CMixPauseNodeRegistrations { + CMixPauseNodeRegistrations( + run: bindingsCMix.pauseNodeRegistrations + ) + } +} + +extension CMixPauseNodeRegistrations { + public static let unimplemented = CMixPauseNodeRegistrations( + run: XCTUnimplemented("\(Self.self)") + ) +} diff --git a/Sources/XXClient/Models/IsReadyInfo.swift b/Sources/XXClient/Models/IsReadyInfo.swift new file mode 100644 index 0000000000000000000000000000000000000000..916f37df7efdc020cc04909324031915f672e8d9 --- /dev/null +++ b/Sources/XXClient/Models/IsReadyInfo.swift @@ -0,0 +1,26 @@ +import Foundation + +public struct IsReadyInfo: Equatable { + public init(isReady: Bool, howClose: Double) { + self.isReady = isReady + self.howClose = howClose + } + + public var isReady: Bool + public var howClose: Double +} + +extension IsReadyInfo: Codable { + enum CodingKeys: String, CodingKey { + case isReady = "IsReady" + case howClose = "HowClose" + } + + public static func decode(_ data: Data) throws -> Self { + try JSONDecoder().decode(Self.self, from: data) + } + + public func encode() throws -> Data { + try JSONEncoder().encode(self) + } +} diff --git a/Tests/XXClientTests/Models/IsReadyInfoTests.swift b/Tests/XXClientTests/Models/IsReadyInfoTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..9db31131ddf11b895b1bac13424a956ff9c28571 --- /dev/null +++ b/Tests/XXClientTests/Models/IsReadyInfoTests.swift @@ -0,0 +1,26 @@ +import CustomDump +import XCTest +@testable import XXClient + +final class IsReadyInfoTests: XCTestCase { + func testCoding() throws { + let jsonString = """ + { + "IsReady": true, + "HowClose": 0.534 + } + """ + let jsonData = jsonString.data(using: .utf8)! + let model = try IsReadyInfo.decode(jsonData) + + XCTAssertNoDifference(model, IsReadyInfo( + isReady: true, + howClose: 0.534 + )) + + let encodedModel = try model.encode() + let decodedModel = try IsReadyInfo.decode(encodedModel) + + XCTAssertNoDifference(decodedModel, model) + } +}