From 3e9f5b869dd32441fdd3d77091cb33ef4301f244 Mon Sep 17 00:00:00 2001 From: lichao <lichao@aiotlink.com> Date: 星期二, 06 四月 2021 20:26:20 +0800 Subject: [PATCH] use BHCenter. --- src/center.h | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/center.h b/src/center.h index f0a177c..02ec8f4 100644 --- a/src/center.h +++ b/src/center.h @@ -20,6 +20,8 @@ #include "socket.h" #include <functional> +#include <map> +#include <memory> class BHCenter { @@ -27,15 +29,25 @@ public: typedef std::function<bool(ShmSocket &socket, bhome_msg::MsgI &imsg, bhome::msg::BHMsg &msg)> MsgHandler; + static bool Install(const std::string &name, MsgHandler handler, const std::string &mqid, const int mq_len); BHCenter(Socket::Shm &shm); BHCenter(); ~BHCenter() { Stop(); } bool Start(); - bool Stop() { return socket_.Stop(); } + bool Stop(); private: - ShmSocket socket_; + struct CenterInfo { + std::string name_; + MsgHandler handler_; + std::string mqid_; + int mq_len_ = 0; + }; + typedef std::map<std::string, CenterInfo> CenterRecords; + static CenterRecords &Centers(); + + std::map<std::string, std::shared_ptr<ShmSocket>> sockets_; }; #endif // end of include guard: CENTER_TM9OUQTG -- Gitblit v1.8.0