AbstractTransport

Base class for Transport implementations that handles the bookkeeping for onClose, onError and onMessage callback registration, exposing the composed callbacks to subclasses for invocation.

The callbacks are composed: each call to onClose, onError, or onMessage chains the new block after any previously registered ones.

Inheritors

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
abstract suspend fun close()

Closes the transport.

Link copied to clipboard
open override fun onClose(block: () -> Unit)

Callback for when the connection is closed for any reason.

Link copied to clipboard
open override fun onError(block: (Throwable) -> Unit)

Callback for when an error occurs.

Link copied to clipboard
open override fun onMessage(block: suspend (JSONRPCMessage) -> Unit)

Callback for when a message (request or response) is received over the connection.

Link copied to clipboard
abstract suspend fun send(message: JSONRPCMessage, options: TransportSendOptions? = null)

Sends a JSON-RPC message (request or response).

Link copied to clipboard
abstract suspend fun start()

Starts processing messages on the transport, including any connection steps that might need to be taken.