From 4fc07d5d891c251a1fe09c17ee16467d961a8f74 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期三, 14 十二月 2022 15:31:12 +0800 Subject: [PATCH] add interface creg add topic and export symbols --- main.cpp | 25 ++++++++++++++----------- 1 files changed, 14 insertions(+), 11 deletions(-) diff --git a/main.cpp b/main.cpp index 84f63fb..35b6ddf 100644 --- a/main.cpp +++ b/main.cpp @@ -18,11 +18,11 @@ static void pub(const vector<string>& topics){ ignoref(pub); - vector<const char*> pubtpc; - for(auto& t : topics) pubtpc.push_back(t.c_str()); + vector<const char*> tpc; + for(auto& t : topics) tpc.push_back(t.c_str()); creg* reg = make_creg(make_cproc("pub", "pubid"), - NULL, 0, &pubtpc[0], pubtpc.size(), NULL, 0, NULL, 0); + NULL, 0, &tpc[0], tpc.size(), NULL, 0, NULL, 0); void* handle = bus_client_init(NULL, 0, reg); creg_free(reg); @@ -49,11 +49,11 @@ static void sub(const vector<string>& topics){ ignoref(sub); - vector<const char*> pubtpc; - for(auto& t : topics) pubtpc.push_back(t.c_str()); + vector<const char*> tpc; + for(auto& t : topics) tpc.push_back(t.c_str()); creg* reg = make_creg(make_cproc("sub", "subid"), - NULL, 0, NULL, 0, &pubtpc[0], pubtpc.size(), NULL, 0); + NULL, 0, NULL, 0, &tpc[0], tpc.size(), NULL, 0); void* handle = bus_client_init(NULL, 0, reg); creg_free(reg); @@ -70,8 +70,7 @@ ignoref(req); const auto topicl = strlen(topic); - creg* reg = make_creg(make_cproc("request", "requestid"), - NULL, 0, NULL, 0, NULL, 0, NULL, 0); + creg* reg = make_creg_from_cproc(make_cproc("request", "requestid")); void* handle = bus_client_init(NULL, 0, reg); creg_free(reg); @@ -96,10 +95,14 @@ ignoref(reply); const auto topicl = strlen(topic); - vector<const char*> pubtpc{topic}; + vector<const char*> tpc{topic}; - creg* reg = make_creg(make_cproc("reply", "replyid"), - &pubtpc[0], pubtpc.size(), &pubtpc[0], pubtpc.size(), NULL, 0, NULL, 0); + // creg* reg = make_creg(make_cproc("reply", "replyid"), + // &tpc[0], tpc.size(), &tpc[0], tpc.size(), NULL, 0, NULL, 0); + + creg* reg = make_creg_from_cproc(make_cproc("reply", "replyid")); + creg_add_topic_reply(reg, tpc.data(), tpc.size()); + creg_add_topic_pub(reg, tpc.data(), tpc.size()); void* handle = bus_client_init(NULL, 0, reg); creg_free(reg); -- Gitblit v1.8.0