HttpServerSentEventClient

class HttpServerSentEventClient(connectionTimeout: Long = DEFAULT_CONNECTION_TIMEOUT_SECONDS, readTimeout: Long = DEFAULT_READ_TIMEOUT_MINUTES, sseSourceUrl: String)

Custom implementation of OkHttpClient that handles Server Sent Events.

Parameters

connectionTimeout

The minimum time required to establish HTTP connection to the server.

readTimeout

The amount of time it takes to actually receive the response back from the server.

sseSourceUrl

The URL to Server Sent Events source end point (server).

Constructors

Link copied to clipboard
constructor(connectionTimeout: Long = DEFAULT_CONNECTION_TIMEOUT_SECONDS, readTimeout: Long = DEFAULT_READ_TIMEOUT_MINUTES, sseSourceUrl: String)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun enqueue(sseDataHandler: (result: Result<String, String>) -> Unit)

Places server sent event request into http client request queue for asynchronous processing and once the response is received triggers Result handler for processing the received data payload.