respond

inline suspend fun <T : Any, R : Any> BrokerCoroutines.respond(noinline handler: suspend (T) -> R?): 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.

R

the type of the response.

handler

the suspend function to handle incoming messages and produce responses.