Interface RouterMessageHandler
public interface RouterMessageHandler
When a message is to be processed locally by the router it will search
the list of registered handlers for the message type and forward the
message to the handler for processing.
- Since:
- 1.0
- Version:
- 2022-08-30
-
Method Summary
Modifier and TypeMethodDescriptionvoid
handleMsg
(WebsocketRouter router, WebsocketConnection conn, InboundMessage msg) Called when a message destined for the local node is processed by the router.
-
Method Details
-
handleMsg
void handleMsg(WebsocketRouter router, WebsocketConnection conn, InboundMessage msg) throws Exception Called when a message destined for the local node is processed by the router. The message may be a TextMessage or an instance of the expected type. It's up to the handler to convert TextMessage to the correct type for processing.If the handler is going to send a response it is responsible for setting the correct src/dst address on the message so it can be routed correctly.
The connection the message came in on is available for use in special cases but generally shouldn't be used as messages may enter the router in other ways than connections (replies for example) and in a meshed network the inbound connection may not mean much of anything. Again, special cases only where the inbound connection is guaranteed to have meaningful context.
- Parameters:
router
- the websocket router used to send results backconn
- the connection the message came in on (may be null)msg
- the message to handle- Throws:
Exception
-