DefaultConnection

open class DefaultConnection(websocketUrl: String, messageListeningScope: CoroutineScope, eventsBufferSize: Int, var targetInfo: Target.TargetInfo? = null, var owner: Browser? = null) : Connection

Default implementation of the Connection interface.

Inheritors

Constructors

Link copied to clipboard
constructor(websocketUrl: String, messageListeningScope: CoroutineScope, eventsBufferSize: Int, targetInfo: Target.TargetInfo? = null, owner: Browser? = null)

Properties

Link copied to clipboard
open override val events: Flow<Message.Event>
Link copied to clipboard
open override val generatedDomains: MutableMap<KClass<out Domain>, Domain>
Link copied to clipboard
Link copied to clipboard
open override val responses: Flow<Message.Response>
Link copied to clipboard
open val targetId: String?
Link copied to clipboard
open override var targetInfo: Target.TargetInfo?
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
open suspend override fun callCommand(method: String, parameter: JsonElement?, mode: CommandMode): 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
inline fun <T> Connection.send(command: CDP.() -> 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 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.