![]() |
IRSOL
C++ code implementing socket server for interacting with Baumer camera.
|
Handler class that delegates protocol message processing to a lambda or callable. More...
#include <lambda_handler.hpp>
Public Types | |
using | lambda_function_t = std::function< std::vector< out_message_t >(std::shared_ptr< Context >, std::shared_ptr< irsol::server::ClientSession >, T &&)> |
Public Member Functions | |
LambdaHandler (std::shared_ptr< irsol::server::handlers::Context > ctx, lambda_function_t callback) | |
Constructs a LambdaHandler with the given context and callback. | |
![]() | |
virtual std::vector< out_message_t > | operator() (const irsol::types::client_id_t &clientId, T &&message) |
Invokes the handler for a given client and message. | |
Protected Member Functions | |
std::vector< out_message_t > | process (std::shared_ptr< irsol::server::ClientSession > session, T &&message) final override |
Processes the protocol message by invoking the stored lambda/callable. | |
![]() | |
HandlerBase (std::shared_ptr< Context > ctx) | |
Constructs the handler base. | |
Private Attributes | |
lambda_function_t | m_callback |
The lambda or callable to invoke for each message. | |
Additional Inherited Members | |
![]() | |
std::shared_ptr< Context > | ctx |
Handler context (provides access to app and utilities). | |
Handler class that delegates protocol message processing to a lambda or callable.
T | Protocol message type (Assignment, Inquiry, Command). |
LambdaHandler enables protocol message handlers to be implemented as lambda functions or other callable objects, rather than requiring a dedicated handler class.
The lambda receives the handler context, the client session pointer, and the protocol message.
Definition at line 62 of file lambda_handler.hpp.
using irsol::server::handlers::LambdaHandler< T, >::lambda_function_t = std::function<std::vector< out_message_t>(std::shared_ptr<Context>, std::shared_ptr<irsol::server::ClientSession>, T&&)> |
Definition at line 65 of file lambda_handler.hpp.
|
inline |
Constructs a LambdaHandler with the given context and callback.
ctx | Handler context. |
callback | Lambda or callable to invoke for each message. |
Definition at line 73 of file lambda_handler.hpp.
|
inlinefinaloverrideprotectedvirtual |
Processes the protocol message by invoking the stored lambda/callable.
session | The client session. |
message | The protocol message. |
Implements irsol::server::handlers::internal::HandlerBase< T, >.
Definition at line 84 of file lambda_handler.hpp.
|
private |
The lambda or callable to invoke for each message.
Definition at line 93 of file lambda_handler.hpp.