From 68c7bef33e74f23aa0136ccd6f7faa654d671ebc Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期五, 21 五月 2021 09:23:01 +0800 Subject: [PATCH] center publish notify; fix topic partial match. --- box/node_center.h | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/box/node_center.h b/box/node_center.h index 4663bee..4d3fba3 100644 --- a/box/node_center.h +++ b/box/node_center.h @@ -80,17 +80,20 @@ struct ProcState { int64_t timestamp_ = 0; uint32_t flag_ = 0; // reserved - void PutOffline(const int64_t offline_time); - void UpdateState(const int64_t now, const int64_t offline_time, const int64_t kill_time); }; typedef std::unordered_map<Address, std::set<Topic>> AddressTopics; struct NodeInfo { + NodeCenter ¢er_; ProcState state_; // state std::map<MQId, int64_t> addrs_; // registered mqs ProcInfo proc_; // AddressTopics services_; // address: topics AddressTopics subscriptions_; // address: topics + NodeInfo(NodeCenter ¢er) : + center_(center) {} + void PutOffline(const int64_t offline_time); + void UpdateState(const int64_t now, const int64_t offline_time, const int64_t kill_time); }; typedef std::shared_ptr<NodeInfo> Node; typedef std::weak_ptr<NodeInfo> WeakNode; @@ -171,6 +174,7 @@ private: void CheckNodes(); bool CanHeartbeat(const NodeInfo &node) { return Valid(node) || node.state_.flag_ == kStateOffline; } + void Publish(const Topic &topic, const std::string &content); bool Valid(const NodeInfo &node) { return node.state_.flag_ == kStateNormal; } bool Valid(const WeakNode &weak) { -- Gitblit v1.8.0