REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
|
A MessageHandler is a functor/closure like event handler. More...
#include <handler.h>

Public Member Functions | |
constexpr int | error (int internal_code) |
virtual int | handle (JsonObjectConst msg_in, JsonObject &msg_out) |
The actual handler method gets a message and returns a message next to the status code. | |
virtual int | handle (JsonObjectConst msg_in, JsonObject &msg_out, net::auth::AuthentificationContext &user_context) |
A handler variant that allows access to the authentification context of the client. | |
virtual int | handle (JsonObjectConst msg_in, utils::StreamingJson &msg_out) |
Handler for streaming responses. | |
Public Attributes | |
int | result_prefix = 0 |
Following the HRESULT idiom, this number is an assigned prefix by the registry. | |
Static Public Attributes | |
static constexpr int | not_implemented = -99 |
static constexpr int | success = 0 |
Detailed Description
A MessageHandler is a functor/closure like event handler.
Different method signatures are "probed" by the registry.
Member Function Documentation
◆ error()
|
inlineconstexpr |
Definition at line 32 of file handler.h.
References result_prefix, and success.
Referenced by msg::handlers::GetConfigMessageHandler::handle(), msg::handlers::GetOverloadStatusHandler::handle(), msg::handlers::LoadPluginHandler::handle(), msg::handlers::LockAcquire::handle(), msg::handlers::LockRelease::handle(), msg::handlers::LoginHandler::handle(), msg::handlers::ManualControlHandler::handle(), msg::handlers::OneshotDAQHandler::handle(), msg::handlers::ResetRequestHandler::handle(), msg::handlers::SetConfigMessageHandler::handle(), msg::handlers::StartRunRequestHandler::handle(), msg::handlers::StopRunRequestHandler::handle(), and msg::handlers::UnloadPluginHandler::handle().
◆ handle() [1/3]
|
inlinevirtual |
The actual handler method gets a message and returns a message next to the status code.
- Returns
- An error code. 0 means the handling was successful, any nonzero value means something specific to the handler. Handlers should define their error values as constants.
Reimplemented in msg::handlers::FlasherAbortHandler, msg::handlers::FlasherCompleteHandler, msg::handlers::FlasherDataHandler, msg::handlers::FlasherInitHandler, msg::handlers::GetConfigMessageHandler, msg::handlers::GetEntitiesRequestHandler, msg::handlers::GetNetworkSettingsHandler, msg::handlers::GetOverloadStatusHandler, msg::handlers::HelpHandler, msg::handlers::LoadPluginHandler, msg::handlers::ManualControlHandler, msg::handlers::NetworkStatusHandler, msg::handlers::OneshotDAQHandler, msg::handlers::PingRequestHandler, msg::handlers::RebootHandler, msg::handlers::ResetNetworkSettingsHandler, msg::handlers::ResetRequestHandler, msg::handlers::SetConfigMessageHandler, msg::handlers::SetNetworkSettingsHandler, msg::handlers::StartRunRequestHandler, msg::handlers::StopRunRequestHandler, msg::handlers::SystemStats, and msg::handlers::UnloadPluginHandler.
Definition at line 42 of file handler.h.
References not_implemented.
◆ handle() [2/3]
|
inlinevirtual |
A handler variant that allows access to the authentification context of the client.
Reimplemented in msg::handlers::GetSystemIdent, msg::handlers::LockAcquire, msg::handlers::LockRelease, and msg::handlers::LoginHandler.
Definition at line 49 of file handler.h.
References not_implemented.
◆ handle() [3/3]
|
inlinevirtual |
Handler for streaming responses.
Reimplemented in msg::handlers::SyslogHandler.
Definition at line 56 of file handler.h.
References not_implemented.
Member Data Documentation
◆ not_implemented
|
staticconstexpr |
◆ result_prefix
int msg::handlers::MessageHandler::result_prefix = 0 |
Following the HRESULT idiom, this number is an assigned prefix by the registry.
It should always be addded to the return value of handle(). You can use the helper routine error(...) to simplify this.
Definition at line 31 of file handler.h.
Referenced by error(), and msg::handlers::DynamicRegistry::set().
◆ success
|
staticconstexpr |
Definition at line 24 of file handler.h.
Referenced by error(), msg::handlers::GetEntitiesRequestHandler::handle(), msg::handlers::GetNetworkSettingsHandler::handle(), msg::handlers::GetSystemIdent::handle(), msg::handlers::HelpHandler::handle(), msg::handlers::ManualControlHandler::handle(), msg::handlers::NetworkStatusHandler::handle(), msg::handlers::PingRequestHandler::handle(), msg::handlers::RebootHandler::handle(), msg::handlers::ResetNetworkSettingsHandler::handle(), msg::handlers::SetNetworkSettingsHandler::handle(), msg::handlers::StopRunRequestHandler::handle(), msg::handlers::SyslogHandler::handle(), and msg::handlers::SystemStats::handle().
The documentation for this class was generated from the following file:
- lib/communication/src/protocol/handler.h