ChannelTransport

A transport implementation that uses Kotlin Coroutines Channels for asynchronous communication of JSON-RPC messages. This is useful in scenarios where communication is message-based and channels are used as the underlying mechanism for delivery.

Parameters

dispatcher

The coroutine dispatcher for the event loop. Defaults to Dispatchers.Default.

Constructors

Link copied to clipboard
constructor(sendChannel: SendChannel<JSONRPCMessage>, receiveChannel: ReceiveChannel<JSONRPCMessage>, dispatcher: CoroutineDispatcher = Dispatchers.Default)

Initializes the transport with the specified SendChannel and ReceiveChannel.

constructor(channel: Channel<JSONRPCMessage> = Channel(UNLIMITED), dispatcher: CoroutineDispatcher = Dispatchers.Default)

Creates a ChannelTransport instance using a single channel for both sending and receiving messages.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class LinkedTransports(val clientTransport: ChannelTransport, val serverTransport: ChannelTransport)

Represents a pair of interconnected ChannelTransports for bidirectional communication.

Functions

Link copied to clipboard
open suspend override fun close()
Link copied to clipboard
open override fun onClose(block: () -> Unit)
Link copied to clipboard
open override fun onError(block: (Throwable) -> Unit)
Link copied to clipboard
open override fun onMessage(block: suspend (JSONRPCMessage) -> Unit)
Link copied to clipboard
open suspend override fun send(message: JSONRPCMessage, options: TransportSendOptions?)
Link copied to clipboard
open suspend override fun start()