rad
2.0.0
|
#include <msgReplier.hpp>
Public Types | |
using | MsgHandler_t = std::function< void(const std::string &, const std::string &, const void *, size_t)> |
using | MsgHandlerMap_t = std::unordered_map< std::string, MsgHandler_t > |
using | MsgHandler_t = std::function< void(const std::string &, const std::string &, const void *, size_t)> |
using | MsgHandlerMap_t = std::unordered_map< std::string, MsgHandler_t > |
Public Member Functions | |
MsgReplier (const std::string &endpoint, boost::asio::io_service &ios, std::unique_ptr< MsgHandler > &&fallback_handler) | |
virtual | ~MsgReplier () |
MsgReplier (MsgReplier &&)=default | |
void | Start () |
void | Stop () |
void | AddMsgHandler (const std::string &request_name, MsgHandler_t handler) |
size_t | Send (const std::string &identity, const std::string &reply_type, const std::string &reply_payload) |
template<typename REPLY > | |
size_t | Send (const std::string &identity, const REPLY &reply_payload) |
MsgReplier (const MsgReplier &)=delete | |
MsgReplier & | operator= (const MsgReplier &)=delete |
MsgReplier (const std::string &endpoint, boost::asio::io_service &ios, std::unique_ptr< MsgHandler > &&fallback_handler) | |
virtual | ~MsgReplier () |
MsgReplier (MsgReplier &&)=default | |
void | Start () |
void | Stop () |
void | AddMsgHandler (const std::string &request_name, MsgHandler_t handler) |
size_t | Send (const std::string &identity, const std::string &reply_type, const std::string &reply_payload) |
template<typename REPLY > | |
size_t | Send (const std::string &identity, const REPLY &reply_payload) |
MsgReplier (const MsgReplier &)=delete | |
MsgReplier & | operator= (const MsgReplier &)=delete |
template<typename TYPEREP > | |
size_t | Send (const std::string &identity, const TYPEREP &reply_payload) |
Class to receive requests and send replies.
using rad::MsgReplier::MsgHandler_t = std::function<void(const std::string&, const std::string&, const void*, size_t)> |
using rad::MsgReplier::MsgHandler_t = std::function<void(const std::string&, const std::string&, const void*, size_t)> |
using rad::MsgReplier::MsgHandlerMap_t = std::unordered_map<std::string, MsgHandler_t> |
using rad::MsgReplier::MsgHandlerMap_t = std::unordered_map<std::string, MsgHandler_t> |
MsgReplier::MsgReplier | ( | const std::string & | endpoint, |
boost::asio::io_service & | ios, | ||
std::unique_ptr< MsgHandler > && | fallback | ||
) |
Configure socket and bind the socket to the given endpoint (IP address and port).
[in] | endpoint | Address and port to be used to receive requests. |
[in] | ios | Reference to the event loop. |
[in] | fallback | Map of handlers for given requests used if no other handlers are provided (e.g. via the AddMsgHandler() method). |
|
virtual |
Destructor
|
default |
|
delete |
rad::MsgReplier::MsgReplier | ( | const std::string & | endpoint, |
boost::asio::io_service & | ios, | ||
std::unique_ptr< MsgHandler > && | fallback_handler | ||
) |
|
virtual |
|
default |
|
delete |
void MsgReplier::AddMsgHandler | ( | const std::string & | request_name, |
MsgHandler_t | handler | ||
) |
Add a handler for a given request name.
[in] | request_name | Request to handle. |
[in] | handler | Handler for the given request name. |
void rad::MsgReplier::AddMsgHandler | ( | const std::string & | request_name, |
MsgHandler_t | handler | ||
) |
|
delete |
|
delete |
size_t MsgReplier::Send | ( | const std::string & | identity, |
const std::string & | reply_type, | ||
const std::string & | reply_payload | ||
) |
Method to reply to a request.
[in] | identity | Identity of the originator of the request to reply to. |
[in] | reply_type | Type of the payload to be sent with the reply. |
[in] | reply_payload | Payload to be sent with the reply. |
size_t rad::MsgReplier::Send | ( | const std::string & | identity, |
const std::string & | reply_type, | ||
const std::string & | reply_payload | ||
) |
size_t rad::MsgReplier::Send | ( | const std::string & | identity, |
const REPLY & | reply_payload | ||
) |
size_t rad::MsgReplier::Send | ( | const std::string & | identity, |
const REPLY & | reply_payload | ||
) |
size_t rad::MsgReplier::Send | ( | const std::string & | identity, |
const TYPEREP & | reply_payload | ||
) |
void MsgReplier::Start | ( | ) |
Register callback to the socket.
void rad::MsgReplier::Start | ( | ) |
void rad::MsgReplier::Stop | ( | ) |
void MsgReplier::Stop | ( | ) |
Stop processing requests.