protected inline fun <reified Q : AbstractRequestMessage, reified R : Any> addMessageHandler(topic: String, crossinline handler: (Q) -> R, crossinline exceptionConsumer: (Message, Exception) -> Unit): Unit
Register a handler for a message topic. In comparison to using net.addMessageHandler() this manages a lot of common boilerplate code. Exceptions are caught and passed to the provided consumer.
topic
- the topic, without the default session ID postfix (".0)handler
- a function to handle the deserialised request and return a responseexceptionConsumer
- a function to which any thrown exception is passed.protected inline fun <reified Q : AbstractRequestMessage, reified R : Any> addMessageHandler(topic: String, crossinline handler: (Q) -> R): Unit
Register a handler for a message topic. In comparison to using net.addMessageHandler() this manages a lot of common boilerplate code. Exceptions are propagated to the messaging layer.
topic
- the topic, without the default session ID postfix (".0)handler
- a function to handle the deserialised request and return a response