@@ -42,10 +42,17 @@ * * @param exception `nil` on success, otherwise an exception */ typedef void (^mtx_client_response_block_t)(id _Nullable exception); +/** + * @brief A block called when an exception occurred during sync. + * + * @param exception The exception which occurred during sync + */ +typedef void (^mtx_sync_exception_handler_block_t)(id exception); + /** * @brief A block called when the room list was fetched. * * @param rooms An array of joined rooms, or nil on error * @param exception An exception if fetching the room list failed @@ -90,10 +97,23 @@ /** * @brief The storage used by the client. */ @property (readonly, nonatomic) id storage; +/** + * @brief The timeout for sync requests. + * + * Defaults to 5 minutes. + */ +@property (nonatomic) of_time_interval_t syncTimeout; + +/** + * @brief A block to handle exceptions that occurred during sync. + */ +@property (copy, nonatomic) + mtx_sync_exception_handler_block_t syncExceptionHandler; + /** * @brief Creates a new client with the specified access token on the specified * homeserver. * * @param userID The user ID for the client @@ -141,16 +161,21 @@ homeserver: (OFURL *)homeserver storage: (id )storage OF_DESIGNATED_INITIALIZER; /** - * @brief Performs a sync. + * @brief Starts the sync loop. + */ +- (void)startSyncLoop; + +/** + * @brief Stops the sync loop. * - * @param block A block to call when a sync was performed + * The currently waiting sync is not aborted, but after it returns, no new sync + * will be started. */ -- (void)syncWithTimeout: (of_time_interval_t)timeout - block: (mtx_client_response_block_t)block; +- (void)stopSyncLoop; /** * @brief Logs out the device and invalidates the access token. * * @warning The client can no longer be used after this succeeded!