DefaultConnection

open class DefaultConnection(websocketUrl: String, messageListeningScope: CoroutineScope, var targetInfo: <Error class: unknown class>? = null, var owner: Browser? = null) : OwnedConnection

Default implementation of the Connection interface.

Inheritors

Constructors

Link copied to clipboard
constructor(websocketUrl: String, messageListeningScope: CoroutineScope, targetInfo: <Error class: unknown class>? = null, owner: Browser? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open val attached: Boolean?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open val events: Flow<<Error class: unknown class>>
Link copied to clipboard
open val generatedDomains: MutableMap<KClass<out <Error class: unknown class>>, <Error class: unknown class>>
Link copied to clipboard
Link copied to clipboard
open val openerId: String?
Link copied to clipboard
open override var owner: Browser?
Link copied to clipboard
open val responses: Flow<<Error class: unknown class>>
Link copied to clipboard
open val subtype: String?
Link copied to clipboard
open val targetId: String?
Link copied to clipboard
open override var targetInfo: <Error class: unknown class>?
Link copied to clipboard
open val title: String?
Link copied to clipboard
open val type: String?
Link copied to clipboard
open val url: String?

Functions

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

Adds a handler for a specific CDP event.

Link copied to clipboard
open suspend override fun callCommand(method: String, parameter: JsonElement?, mode: <Error class: unknown class>): JsonElement?

Internal method to call a CDP command.

Link copied to clipboard
open suspend override fun close()

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

Link copied to clipboard
open suspend override fun registerReconnectRestore(key: Any, restore: suspend () -> Unit)

Registers a restore action to be re-run automatically after the connection transparently reconnects.

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

Sends a CDP command and waits for the response.

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

Suspends the coroutine for a specified time in milliseconds.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open suspend override fun unregisterReconnectRestore(key: Any)

Removes a restorer previously registered with registerReconnectRestore. No-op if key is not registered.

Link copied to clipboard
open suspend override fun updateTarget()

Updates the target information by fetching it from the CDP.

Link copied to clipboard
open suspend override fun wait(t: Long?)

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.