|
ORE Studio 0.0.4
|
Dispatches incoming messages to registered subsystem handlers. More...
#include <message_dispatcher.hpp>

Public Member Functions | |
| message_dispatcher (std::shared_ptr< service::auth_session_service > sessions) | |
| Construct a message dispatcher with auth session service. | |
| void | register_handler (message_type_range range, std::shared_ptr< message_handler > handler) |
| Register a handler for a range of message types. | |
| boost::asio::awaitable< std::expected< frame, error_code > > | dispatch (const frame &request_frame, std::uint32_t sequence, const std::string &remote_address, compression_type response_compression=compression_type::none) |
| Dispatch a request frame to the appropriate handler. | |
Dispatches incoming messages to registered subsystem handlers.
The dispatcher maintains a registry of message handlers for different message type ranges. When a message arrives, it routes it to the appropriate handler based on the message type, and converts the handler's response back into a frame.
Thread-safety: This class is not thread-safe. Registration should happen during initialization before concurrent access begins.
|
explicit |
Construct a message dispatcher with auth session service.
| sessions | Shared auth session service for authorization |
| void register_handler | ( | message_type_range | range, |
| std::shared_ptr< message_handler > | handler | ||
| ) |
Register a handler for a range of message types.
| range | The range of message types this handler processes |
| handler | The handler implementation |
Note: Ranges must not overlap. Behavior is undefined if overlapping ranges are registered.
| boost::asio::awaitable< std::expected< frame, error_code > > dispatch | ( | const frame & | request_frame, |
| std::uint32_t | sequence, | ||
| const std::string & | remote_address, | ||
| compression_type | response_compression = compression_type::none |
||
| ) |
Dispatch a request frame to the appropriate handler.
Finds the registered handler for the message type, invokes it, and wraps the response payload in a frame with the appropriate response message type.
| request_frame | The incoming request frame |
| sequence | The sequence number for the response frame |
| remote_address | The remote endpoint address of the client connection |
| response_compression | Compression type to use for response frame |