| | |
| | | class TopicNode |
| | | { |
| | | SharedMemory &shm_; |
| | | MsgRegister info_; |
| | | ProcInfo info_; |
| | | |
| | | SharedMemory &shm() { return shm_; } |
| | | |
| | |
| | | bool ServerSendReply(void *src_info, const MsgRequestTopicReply &reply); |
| | | |
| | | // topic client |
| | | typedef std::function<void(const std::string &proc_id, const MsgRequestTopicReply &reply)> RequestResultCB; |
| | | typedef std::function<void(const BHMsgHead &head, const MsgRequestTopicReply &reply)> RequestResultCB; |
| | | bool ClientStartWorker(RequestResultCB const &cb, const int nworker = 2); |
| | | bool ClientAsyncRequest(const MsgRequestTopic &request, const RequestResultCB &rrcb = RequestResultCB()); |
| | | bool ClientAsyncRequest(const MsgRequestTopic &request, std::string &msg_id, const RequestResultCB &rrcb = RequestResultCB()); |
| | | bool ClientSyncRequest(const MsgRequestTopic &request, std::string &proc_id, MsgRequestTopicReply &reply, const int timeout_ms); |
| | | |
| | | // publish |
| | |
| | | // subscribe |
| | | typedef std::function<void(const std::string &proc_id, const MsgPublish &data)> SubDataCB; |
| | | bool SubscribeStartWorker(const SubDataCB &tdcb, int nworker = 2); |
| | | bool Subscribe(MsgTopicList &topics, const int timeout_ms); |
| | | bool Subscribe(MsgTopicList &topics, MsgCommonReply &reply_body, const int timeout_ms); |
| | | bool RecvSub(std::string &proc_id, MsgPublish &pub, const int timeout_ms); |
| | | |
| | | void Start(ServerCB const &server_cb, SubDataCB const &sub_cb); |
| | | void Start(ServerCB const &server_cb, SubDataCB const &sub_cb, RequestResultCB &client_cb, int nworker = 2); |
| | | void Stop(); |
| | | |
| | | private: |
| | | bool ClientQueryRPCTopic(const Topic &topic, bhome::msg::BHAddress &addr, const int timeout_ms); |
| | | const std::string &proc_id() { return info_.proc().proc_id(); } |
| | | const std::string &proc_id() { return info_.proc_id(); } |
| | | |
| | | typedef bhome_msg::BHAddress Address; |
| | | class TopicQueryCache |
| | |
| | | auto &SockClient() { return SockRequest(); } |
| | | auto &SockReply() { return sock_reply_; } |
| | | auto &SockServer() { return SockReply(); } |
| | | bool IsRegistered() const { return registered_.load(); } |
| | | |
| | | std::atomic<bool> registered_; |
| | | ShmSocket sock_node_; |
| | | ShmSocket sock_request_; |
| | | ShmSocket sock_reply_; |