rad 6.2.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
rad::MsgReplier Class Reference

#include <msgReplier.hpp>

Public Types

using MsgHandler_t
 
using MsgHandlerMap_t = std::unordered_map<std::string, MsgHandler_t>
 

Public Member Functions

 MsgReplier (const std::string &endpoint, boost::asio::io_context &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
 
MsgReplieroperator= (const MsgReplier &)=delete
 
template<typename TYPEREP >
size_t Send (const std::string &identity, const TYPEREP &reply_payload)
 

Detailed Description

Class to receive requests and send replies.

Member Typedef Documentation

◆ MsgHandler_t

Initial value:
std::function<void(const std::string&, const std::string&, const void*, size_t)>

◆ MsgHandlerMap_t

using rad::MsgReplier::MsgHandlerMap_t = std::unordered_map<std::string, MsgHandler_t>

Constructor & Destructor Documentation

◆ MsgReplier() [1/3]

MsgReplier::MsgReplier ( const std::string & endpoint,
boost::asio::io_context & ios,
std::unique_ptr< MsgHandler > && fallback )

Configure socket and bind the socket to the given endpoint (IP address and port).

Parameters
[in]endpointAddress and port to be used to receive requests.
[in]iosReference to the event loop.
[in]fallbackMap of handlers for given requests used if no other handlers are provided (e.g. via the AddMsgHandler() method).

◆ ~MsgReplier()

MsgReplier::~MsgReplier ( )
virtual

Destructor

◆ MsgReplier() [2/3]

rad::MsgReplier::MsgReplier ( MsgReplier && )
default

◆ MsgReplier() [3/3]

rad::MsgReplier::MsgReplier ( const MsgReplier & )
delete

Member Function Documentation

◆ AddMsgHandler()

void MsgReplier::AddMsgHandler ( const std::string & request_name,
MsgHandler_t handler )

Add a handler for a given request name.

Parameters
[in]request_nameRequest to handle.
[in]handlerHandler for the given request name.

◆ operator=()

MsgReplier & rad::MsgReplier::operator= ( const MsgReplier & )
delete

◆ Send() [1/3]

template<typename REPLY >
size_t rad::MsgReplier::Send ( const std::string & identity,
const REPLY & reply_payload )

◆ Send() [2/3]

size_t MsgReplier::Send ( const std::string & identity,
const std::string & reply_type,
const std::string & reply_payload )

Method to reply to a request.

Parameters
[in]identityIdentity of the originator of the request to reply to.
[in]reply_typeType of the payload to be sent with the reply.
[in]reply_payloadPayload to be sent with the reply.
Returns
the number of bytes sent with the reply.

◆ Send() [3/3]

template<typename TYPEREP >
size_t rad::MsgReplier::Send ( const std::string & identity,
const TYPEREP & reply_payload )

◆ Start()

void MsgReplier::Start ( )

Register callback to the socket.

◆ Stop()

void MsgReplier::Stop ( )

Stop processing requests.


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