rad  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
rad::MsgReplier Class Reference

#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
 
MsgReplieroperator= (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
 
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

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>

Constructor & Destructor Documentation

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).

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 ( )
virtual

Destructor

rad::MsgReplier::MsgReplier ( MsgReplier &&  )
default
rad::MsgReplier::MsgReplier ( const MsgReplier )
delete
rad::MsgReplier::MsgReplier ( const std::string &  endpoint,
boost::asio::io_service &  ios,
std::unique_ptr< MsgHandler > &&  fallback_handler 
)
virtual rad::MsgReplier::~MsgReplier ( )
virtual
rad::MsgReplier::MsgReplier ( MsgReplier &&  )
default
rad::MsgReplier::MsgReplier ( const MsgReplier )
delete

Member Function Documentation

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.
void rad::MsgReplier::AddMsgHandler ( const std::string &  request_name,
MsgHandler_t  handler 
)
MsgReplier& rad::MsgReplier::operator= ( const MsgReplier )
delete
MsgReplier& rad::MsgReplier::operator= ( const MsgReplier )
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.

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.
size_t rad::MsgReplier::Send ( const std::string &  identity,
const std::string &  reply_type,
const std::string &  reply_payload 
)
template<typename REPLY >
size_t rad::MsgReplier::Send ( const std::string &  identity,
const REPLY &  reply_payload 
)
template<typename REPLY >
size_t rad::MsgReplier::Send ( const std::string &  identity,
const REPLY &  reply_payload 
)
template<typename TYPEREP >
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.


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