createLinkedPair
fun createLinkedPair(capacity: Int = 256, dispatcher: CoroutineDispatcher = Dispatchers.Default): ChannelTransport.LinkedTransports(source)
Creates a pair of interconnected ChannelTransport objects for bidirectional communication.
Sets up a client and server transport using Kotlin channels, so that messages sent through one transport are received by the other. Typically used for testing or in-memory communication without external networking.
Example:
val (clientTransport, serverTransport) = ChannelTransport.createLinkedPair()
server.connect(serverTransport)
client.connect(clientTransport)Content copied to clipboard
Return
A LinkedTransports instance containing the client and server transports.
Parameters
capacity
The buffer capacity of the internal channels used for communication. Defaults to 256.
dispatcher
The coroutine dispatcher for the event loop. Defaults to Dispatchers.Default.