9 #ifndef RAD_SM_REQUESTOR_HPP
10 #define RAD_SM_REQUESTOR_HPP
12 #include <rad/AnyEvent.hpp>
13 #include <rad/Dispatcher.hpp>
14 #include <rad/MsgRequestor.hpp>
15 #include <rad/MsgHandler.hpp>
22 template<
typename TYPEREQ,
typename TYPEREP>
27 const std::string& identity,
28 boost::asio::io_service& ios,
35 size_t Send(
const TYPEREQ& payload,
const long timeout = 0);
50 TYPEREP mReplyPayload;
58 template<
typename TYPEREQ,
typename TYPEREP>
60 const std::string& identity,
61 boost::asio::io_service& ios,
66 : mMsgRequestor(endpoint, identity, ios, std::bind(&
SMRequestor<TYPEREQ, TYPEREP>::ReplyHandler, this, std::placeholders::_1, std::placeholders::_2)),
67 mDispatcher(dispatcher),
68 mOkEvent(std::move(okEvent)),
69 mErrEvent(std::move(errEvent)),
70 mTimeoutEvent(std::move(timeoutEvent))
78 template<
typename TYPEREQ,
typename TYPEREP>
93 template<
typename TYPEREQ,
typename TYPEREP>
97 return mMsgRequestor.Send(payload, timeout);
100 template<
typename TYPEREQ,
typename TYPEREP>
106 mReplyPayload =
reply;
109 mDispatcher.dispatch(*mOkEvent);
111 mDispatcher.dispatch(*mTimeoutEvent);
116 template<
typename TYPEREQ,
typename TYPEREP>
120 return mReplyPayload;
Definition: SMRequestor.hpp:23
SMRequestor(const std::string &endpoint, const std::string &identity, boost::asio::io_service &ios, rad::Dispatcher &dispatcher, UniqueEvent &&okEvent, UniqueEvent &&errEvent, UniqueEvent &&timeoutEvent)
Definition: SMRequestor.hpp:59
SMRequestor & operator=(const SMRequestor &)=delete
size_t Send(const TYPEREQ &payload, const long timeout=0)
Definition: SMRequestor.hpp:94
optional bool timeout
Definition: requests.proto:13
const TYPEREP & GetReplyPayload()
Definition: SMRequestor.hpp:117
Definition: Dispatcher.hpp:22
std::unique_ptr< AnyEvent > UniqueEvent
Definition: AnyEvent.hpp:48
optional string reply
Definition: requests.proto:26
#define RAD_LOG_TRACE()
Definition: Logger.hpp:319
Definition: MsgRequestor.hpp:34
optional int32 error_code
Definition: topics.proto:14
virtual ~SMRequestor()
Definition: SMRequestor.hpp:79