IRSOL
C++ code implementing socket server for interacting with Baumer camera.
MyAssignmentHandler Class Reference

Example custom handler for Assignment messages. More...

Inheritance diagram for MyAssignmentHandler:
irsol::server::handlers::internal::HandlerBase< T, >

Public Member Functions

 MyAssignmentHandler (std::shared_ptr< irsol::server::handlers::Context > ctx)
 
std::vector< irsol::server::handlers::out_message_toperator() (IRSOL_MAYBE_UNUSED const irsol::types::client_id_t &clientId, irsol::protocol::Assignment &&message) override
 
- Public Member Functions inherited from irsol::server::handlers::internal::HandlerBase< T, >
virtual std::vector< out_message_toperator() (const irsol::types::client_id_t &clientId, T &&message)
 Invokes the handler for a given client and message.
 

Protected Member Functions

std::vector< irsol::server::handlers::out_message_tprocess (IRSOL_MAYBE_UNUSED std::shared_ptr< irsol::server::ClientSession > client, irsol::protocol::Assignment &&message) override
 
- Protected Member Functions inherited from irsol::server::handlers::internal::HandlerBase< T, >
 HandlerBase (std::shared_ptr< Context > ctx)
 Constructs the handler base.
 
virtual std::vector< out_message_tprocess (std::shared_ptr< irsol::server::ClientSession > session, T &&message)=0
 Processes the protocol message for the given session.
 

Additional Inherited Members

- Protected Attributes inherited from irsol::server::handlers::internal::HandlerBase< T, >
std::shared_ptr< Contextctx
 Handler context (provides access to app and utilities).
 

Detailed Description

Example custom handler for Assignment messages.

Definition at line 23 of file main.cpp.

Constructor & Destructor Documentation

◆ MyAssignmentHandler()

MyAssignmentHandler::MyAssignmentHandler ( std::shared_ptr< irsol::server::handlers::Context ctx)
inline

Definition at line 26 of file main.cpp.

28 {}
std::shared_ptr< Context > ctx
Handler context (provides access to app and utilities).
Definition base.hpp:81
internal::HandlerBase< protocol::Assignment > AssignmentHandler
Handler type for assignment messages.
Definition base.hpp:88

Member Function Documentation

◆ operator()()

std::vector< irsol::server::handlers::out_message_t > MyAssignmentHandler::operator() ( IRSOL_MAYBE_UNUSED const irsol::types::client_id_t clientId,
irsol::protocol::Assignment &&  message 
)
inlineoverride

Overrides the base operator() as we skip the collection of the client's Session in this demo, which is the behavior of the base class.

Definition at line 32 of file main.cpp.

35 {
36 return process(nullptr, std::move(message));
37 }
std::vector< irsol::server::handlers::out_message_t > process(IRSOL_MAYBE_UNUSED std::shared_ptr< irsol::server::ClientSession > client, irsol::protocol::Assignment &&message) override
Definition main.cpp:40

◆ process()

std::vector< irsol::server::handlers::out_message_t > MyAssignmentHandler::process ( IRSOL_MAYBE_UNUSED std::shared_ptr< irsol::server::ClientSession client,
irsol::protocol::Assignment &&  message 
)
inlineoverrideprotected

Definition at line 40 of file main.cpp.

43 {
44 IRSOL_LOG_INFO("[MyAssignmentHandler] Called with {}.", message.toString());
45 // Respond with a Success message
46 // Due to move-only semantics of `Success`, we must create the response vector
47 // in this way. Using brace-initialization like `return
48 // {irsol::protocol::Success::from(message)};` would not work here.
49 std::vector<irsol::server::handlers::out_message_t> result;
50 result.emplace_back(irsol::protocol::Success::from(message));
51 return result;
52 }
#define IRSOL_LOG_INFO(...)
Logs an info-level message using the default logger.
Definition logging.hpp:92
std::string toString() const
Converts the assignment to a human-readable string.
static Success from(const Assignment &msg, std::optional< irsol::types::protocol_value_t > overrideValue=std::nullopt)
Creates a success message from an Assignment.
Definition success.hpp:75
auto result

The documentation for this class was generated from the following file: