DBRpcTask

@interface DBRpcTask <TResponse, TError> : DBTask

Dropbox RPC-style Network Task.

After an RPC network request is made via DBTransportClient, a subclass of DBRpcTask is returned, from which response and progress handlers can be installed, and the network response paused or cancelled.

TResponse is the generic representation of the route-specific result, and TError is the generic representation of the route-specific error.

Response / error deserialization is performed with this class.

  • Installs a response handler for the current request.

    Executes handler on main queue/thread.

    Note

    Any existing handlers are replaced by the supplied handler.

    Declaration

    Objective-C

    - (nonnull DBRpcTask<TResponse, TError> *)setResponseBlock:
        (nonnull DBRpcResponseBlock)responseBlock;

    Swift

    func setResponseBlock(_ responseBlock: @escaping (TResponse?, TError?, DBRequestError?) -> Void) -> DBRpcTask<TResponse, TError>

    Parameters

    responseBlock

    The handler block to be executed in the event of a successful or unsuccessful network request. The first argument is the route-specific result. The second argument is the route-specific error. And the third argument is the more general network error (which includes information like Dropbox request ID, http status code, etc.).

    Return Value

    The current DBRpcTask instance.

  • Installs a response handler for the current request with a specific queue on which to execute handler code.

    Executes handler on supplied queue/thread.

    Note

    Any existing handlers are replaced by the supplied handler.

    Declaration

    Objective-C

    - (nonnull DBRpcTask<TResponse, TError> *)
    setResponseBlock:(nonnull DBRpcResponseBlock)responseBlock
               queue:(nullable NSOperationQueue *)queue;

    Swift

    func setResponseBlock(_ responseBlock: @escaping (TResponse?, TError?, DBRequestError?) -> Void, queue: OperationQueue?) -> DBRpcTask<TResponse, TError>

    Parameters

    responseBlock

    The handler block to be executed in the event of a successful or unsuccessful network request. The first argument is the route-specific result. The second argument is the route-specific error. And the third argument is the more general network error (which includes information like Dropbox request ID, http status code, etc.).

    queue

    The operation queue on which to execute the response.

    Return Value

    The current DBRpcTask instance.

  • Installs a progress handler for the current request.

    Executes handler on main queue/thread.

    Note

    Any existing handlers are replaced by the supplied handler.

    Declaration

    Objective-C

    - (nonnull DBRpcTask *)setProgressBlock:(nonnull DBProgressBlock)progressBlock;

    Swift

    func setProgressBlock(_ progressBlock: @escaping DBProgressBlock) -> DBRpcTask<AnyObject, AnyObject>

    Parameters

    progressBlock

    The progress block to be executed in the event of a request update. The first argument is the number of bytes sent. The second argument is the number of total bytes sent. And the third argument is the number of total bytes expected to be sent.

    Return Value

    The current DBRpcTask instance.

  • Installs a progress handler for the current request.

    Executes handler on supplied queue/thread.

    Note

    Any existing handlers are replaced by the supplied handler.

    Declaration

    Objective-C

    - (nonnull DBRpcTask *)setProgressBlock:(nonnull DBProgressBlock)progressBlock
                                      queue:(nullable NSOperationQueue *)queue;

    Swift

    func setProgressBlock(_ progressBlock: @escaping DBProgressBlock, queue: OperationQueue?) -> DBRpcTask<AnyObject, AnyObject>

    Parameters

    progressBlock

    The progress block to be executed in the event of a request update. The first argument is the number of bytes sent. The second argument is the number of total bytes sent. And the third argument is the number of total bytes expected to be sent.

    queue

    The operation queue on which to execute the response.

    Return Value

    The current DBRpcTask instance.