9 #ifndef RAD_MSG_REPLIER_HPP
10 #define RAD_MSG_REPLIER_HPP
12 #include <rad/MsgHandler.hpp>
13 #include <rad/Logger.hpp>
14 #include <rad/Assert.hpp>
16 #include <azmq/socket.hpp>
17 #include <azmq/message.hpp>
19 #include <boost/asio.hpp>
32 using MsgHandler_t = std::function<void (const std::string&, const std::string&, const void*, size_t)>;
36 boost::asio::io_service& ios,
37 std::unique_ptr<MsgHandler>&& fallbackHandler);
46 size_t Send(
const std::string& identity,
47 const std::string& replyType,
48 const std::string& replyPayload);
50 template<
typename REPLY>
51 size_t Send(
const std::string& identity,
const REPLY& replyPayload);
57 std::string mEndpoint;
58 boost::asio::io_service& mIOS;
59 azmq::router_socket mSocket;
60 std::unique_ptr<MsgHandler> mFallbackHandler;
67 template<
typename TYPEREP>
73 std::string replyType = replyPayload.GetDescriptor()->full_name();
76 if (replyPayload.SerializeToString(&str) ==
false) {
77 RAD_LOG_ERROR() <<
"Failed serializing to string payload type <" << replyType <<
">";
81 return Send(identity, replyType, str);
void Start()
Definition: MsgReplier.cpp:82
Definition: MsgReplier.hpp:29
#define RAD_ASSERTPTR(a)
Definition: Assert.hpp:16
#define RAD_LOG_ERROR()
Definition: Logger.hpp:266
std::unordered_map< std::string, MsgHandler_t > MsgHandlerMap_t
Definition: MsgReplier.hpp:33
std::function< void(const std::string &, const std::string &, const void *, size_t)> MsgHandler_t
Definition: MsgReplier.hpp:32
void Stop()
Definition: MsgReplier.cpp:93
optional string msg
Definition: topics.proto:7
MsgReplier & operator=(const MsgReplier &)=delete
virtual ~MsgReplier()
Definition: MsgReplier.cpp:47
size_t Send(const std::string &identity, const std::string &replyType, const std::string &replyPayload)
Definition: MsgReplier.cpp:61
def handler
Definition: test_dispatcher.py:11
void AddMsgHandler(const std::string &requestName, MsgHandler_t handler)
Definition: MsgReplier.cpp:108
#define RAD_LOG_TRACE()
Definition: Logger.hpp:319
optional int32 error_code
Definition: topics.proto:14
MsgReplier(const std::string &endpoint, boost::asio::io_service &ios, std::unique_ptr< MsgHandler > &&fallbackHandler)
Definition: MsgReplier.cpp:26