NetworkClient

interface NetworkClient

Utility class for making asynchronous Http requests.

Requests will be made on an IO thread, but any completions will be executed on the Tealium background thread.

Each client has a fixed list of RequestInterceptors that decide whether a failed request is retried. The shared client in NetworkUtilities.networkClient has none, so it makes a single attempt per request; use newClient to derive a client that retries, e.g. with RequestInterceptors.retryWithBackoff and RequestInterceptors.retryWhenConnected.

Functions

Link copied to clipboard

Creates a NetworkHelper that sends every request through this client.

Link copied to clipboard
open fun newClient(additionalInterceptors: List<RequestInterceptor>): NetworkClient

Same as newClient with a maxRetryCount, with no limit on the number of retries.

abstract fun newClient(additionalInterceptors: List<RequestInterceptor>, maxRetryCount: Int?): NetworkClient

Creates a new NetworkClient from this instance which will also use the given interceptors.

Link copied to clipboard
abstract fun sendRequest(request: HttpRequest, completion: Callback<NetworkResult>): Disposable

Sends an HTTP request asynchronously and returns the result to the provided completion block. The request is retried, when necessary, as decided by this client's interceptors, based on the provided request and the response NetworkResult.

abstract fun sendRequest(request: HttpRequest.Builder, completion: Callback<NetworkResult>): Disposable

Builds the request and sends it asynchronously, returning the result to the provided completion block.