File was renamed from src/reqrep.h |
| | |
| | | /* |
| | | * ===================================================================================== |
| | | * |
| | | * Filename: reqrep.h |
| | | * Filename: topic_request.h |
| | | * |
| | | * Description: topic request/reply sockets |
| | | * Description: topic request socket |
| | | * |
| | | * Version: 1.0 |
| | | * Created: 2021年04月01日 09时36分06秒 |
| | |
| | | * |
| | | * ===================================================================================== |
| | | */ |
| | | #ifndef REQREP_ACEH09NK |
| | | #define REQREP_ACEH09NK |
| | | #ifndef TOPIC_REQUEST_ACEH09NK |
| | | #define TOPIC_REQUEST_ACEH09NK |
| | | |
| | | #include "bh_util.h" |
| | | #include "defs.h" |
| | |
| | | TopicCache topic_cache_; |
| | | }; |
| | | |
| | | class SocketReply : private ShmSocket |
| | | { |
| | | typedef ShmSocket Socket; |
| | | |
| | | public: |
| | | SocketReply(Socket::Shm &shm) : |
| | | Socket(shm, 64) {} |
| | | SocketReply() : |
| | | SocketReply(BHomeShm()) {} |
| | | ~SocketReply() { Stop(); } |
| | | |
| | | typedef std::function<bool(const std::string &topic, const std::string &data, std::string &reply)> OnRequest; |
| | | bool StartWorker(const OnRequest &rcb, int nworker = 2); |
| | | bool Stop() { return Socket::Stop(); } |
| | | bool RecvRequest(void *&src_info, std::string &topic, std::string &data, const int timeout_ms); |
| | | bool SendReply(void *src_info, const std::string &data, const int timeout_ms); |
| | | bool Register(const ProcInfo &proc_info, const std::vector<std::string> &topics, const int timeout_ms); |
| | | bool Heartbeat(const ProcInfo &proc_info, const int timeout_ms); |
| | | |
| | | private: |
| | | }; |
| | | |
| | | #endif // end of include guard: REQREP_ACEH09NK |
| | | #endif // end of include guard: TOPIC_REQUEST_ACEH09NK |