respond

abstract suspend fun <T : Any, Y : Any> respond(responder: ResponderCoroutines<T, Y>): AutoCloseable

Registers a responder to handle incoming messages of a specific type and produce a response.

Return

an AutoCloseable that can be used to unregister the responder.

Parameters

T

the type of the request message.

Y

the type of the response.

responder

the responder to handle incoming messages and produce responses.


abstract suspend fun <T : Any, Y : Any> respond(type: KClass<T>, responder: suspend (T) -> Y?): AutoCloseable

Registers a function to respond to incoming messages of a specific type.

Return

an AutoCloseable that can be used to unregister the responder.

Parameters

T

the type of the request message.

Y

the type of the response.

type

the KClass representing the type of the request message.

responder

the suspend function to handle incoming messages and produce responses.