| | |
| | | #include <string> |
| | | #include <thread> |
| | | #include <memory> |
| | | using namespace std; |
| | | |
| | | #include "cbhomeclient.h" |
| | | #include "message.h" |
| | | |
| | | // #include "3dparty/bus_nng/bn_api.h" |
| | | // #include "3rdparty/bus_nng/bn_api.h" |
| | | #include "bhome_msg_api.pb.h" |
| | | |
| | | using namespace std; |
| | | using namespace bhome_msg; |
| | | |
| | | template <class F> void ignoref(F&& f){} |
| | |
| | | auto msg = bus_client_get_submsg(handle); |
| | | printf("SUB msg topic [%s] data [%s]\n", msg->topic, msg->msg); |
| | | free_submsg(msg); |
| | | |
| | | size_t count = 0; |
| | | auto p = bus_client_query_procs(handle, &count); |
| | | printf("bus_client_query_procs size %lu\n", count); |
| | | free_query_procs(p, count); |
| | | } |
| | | |
| | | bus_client_free(handle); |
| | |
| | | void* src = NULL; |
| | | auto msg = bus_client_get_reqmsg(handle, &src); |
| | | auto repmsg = make_reply_msg(0, NULL, 0, "recv request", 12); |
| | | bus_client_reply_msg(handle, src, repmsg); |
| | | bus_client_reply(handle, src, repmsg); |
| | | free_reply_msg(repmsg); |
| | | printf("REPREQ msg [%s] \n", msg->msg); |
| | | |
| | |
| | | printf("start RR\n"); |
| | | const char* rrtopic = "cbhomeclient_req_rep"; |
| | | thread([&]{ req(rrtopic); }).detach(); |
| | | |
| | | reply(rrtopic); |
| | | |
| | | return 0; |