MutableStream

Kotlin-only implementation of a bi-directional stream.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open override fun close()

Schedule a close event for this stream. After this method is called, the stream will reject any new events.

Link copied to clipboard
open suspend override fun receive(handler: suspend (Event) -> Response)

Install a handler for incoming events. The handler will be called for each incoming event, and the response returned by the handler will be sent back to the sender of the event.

Link copied to clipboard
open fun receiveIn(coroutineScope: CoroutineScope, handler: suspend (Event) -> Response): Job

Install a handler for incoming events in a new coroutine. The handler will be called for each incoming event, and the response returned by the handler will be sent back to the sender of the event.

Link copied to clipboard
open suspend override fun send(event: Event): Response

Send an event and suspend until the response is available.

Link copied to clipboard
suspend fun <Event, Response> SendStream<Event, Response>.sendAndExpectResponse(event: Event, expectedResponse: Response, actions: suspend () -> Unit)