Override this method to handle a message received via the eventbus.
Override this method to handle a message received via the eventbus. This function reads the
action
parameter out of the message and checks if the returned PartialFunction
is defined
on it. With the returned BusModReply
, you can easily tell whether the message resulted in an
error or everything went well by replying Ok
.
A partial function consisting of an "action" -> BusModReply.
Extend this trait to get an easy to use interface for your EventBus module. It relies on the sender sending JSON requests with an
{"action":"<something>"}
. It will reply with either a{"status":"ok"}
JSON object or an{"status":"error", "error":"<ERROR_CODE>", "message":"<detailed message of error>"}
. You can provide extra fields in your reply, by adding a JsonObject to your reply (Ok
orError
). If you need to do something asynchronously while processing the message, useAsyncReply
. You just need to map theFuture
to one of theOk
orError
replies. Exceptions that you forget to catch will always yield a "MODULE_EXCEPTION" error code.