ReceiveStream

An RPC-like stream for returning responses to sent events. The main use case is communication between the JVM and native code, but it can be used for any bi-directional communication.

The stream is called "ReceiveStream" in the JVM and "SendStream" in the native code.

Docs: https://gp.acrobits.cz/master/documentation/core/android/writing-modern-android/streams

Inheritors

Functions

Link copied to clipboard
abstract 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
abstract suspend 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.