Connection

Interface representing a connection to a browser target using the Chrome DevTools Protocol (CDP).

Inheritors

Properties

Link copied to clipboard
abstract val events: Flow<Message.Event>
Link copied to clipboard
Link copied to clipboard
abstract val responses: Flow<Message.Response>
Link copied to clipboard
open val targetId: String?
Link copied to clipboard
Link copied to clipboard
open val type: String?

Functions

Link copied to clipboard
inline fun <T> Connection.addHandler(coroutineScope: CoroutineScope, crossinline event: CDP.() -> Flow<T>, crossinline handler: suspend (T) -> Unit): Job

Adds a handler for a specific CDP event.

Link copied to clipboard
abstract suspend override fun callCommand(method: String, parameter: JsonElement?, mode: CommandMode): JsonElement?

Internal method to call a CDP command.

Link copied to clipboard
abstract suspend fun close()

Closes the websocket connection. Should not be called manually by users.

Link copied to clipboard
inline fun <T> Connection.send(command: CDP.() -> T): T

Sends a CDP command and waits for the response.

Link copied to clipboard
abstract suspend fun sleep(t: Long)

Suspends the coroutine for a specified time in milliseconds.

Link copied to clipboard
abstract suspend fun updateTarget()

Updates the target information by fetching it from the CDP.

Link copied to clipboard
abstract suspend fun wait(t: Long? = null)

Waits until the event listener reports idle (no new events received in a certain timespan). When \`t\` is provided, ensures waiting for \`t\` milliseconds, no matter what.