| | |
| | | #include <string> |
| | | #include <thread> |
| | | #include <vector> |
| | | |
| | | using namespace bhome_msg; |
| | | |
| | | template <class A, class B> |
| | |
| | | const int timeout = 1000; |
| | | auto Sub = [&](int id, const std::vector<std::string> &topics) { |
| | | DemoNode client("client_" + std::to_string(id), shm); |
| | | |
| | | bool r = client.Subscribe(topics, timeout); |
| | | MsgTopicList tlist; |
| | | for (auto &t : topics) { |
| | | tlist.add_topic_list(t); |
| | | } |
| | | bool r = client.Subscribe(tlist, timeout); |
| | | if (!r) { |
| | | printf("client subscribe failed.\n"); |
| | | } |
| | |
| | | }; |
| | | server.ServerStart(onData); |
| | | |
| | | MsgRegisterRPC rpc; |
| | | MsgTopicList rpc; |
| | | for (auto &topic : topics) { |
| | | rpc.add_topics(topic); |
| | | rpc.add_topic_list(topic); |
| | | } |
| | | MsgCommonReply reply_body; |
| | | if (!server.RegisterRPC(rpc, reply_body, 100)) { |
| | | if (!server.ServerRegisterRPC(rpc, reply_body, 100)) { |
| | | printf("server register topic failed\n"); |
| | | return; |
| | | } |