| | |
| | | } |
| | | |
| | | string msg(mtl2.SerializeAsString()); |
| | | |
| | | return simple_request(get_url(URLRegTopic), msg.data(), msg.size(), reply, reply_len, timeout_ms); |
| | | const auto& url = get_url(URLRegTopic); |
| | | if (url.empty()) { |
| | | set_last_error("bus_register_topics url empty"); |
| | | return false; |
| | | } |
| | | return simple_request(url, msg.data(), msg.size(), reply, reply_len, timeout_ms); |
| | | } |
| | | |
| | | int bus_query_topic_address(void* handle, const void *remote, |
| | |
| | | } |
| | | |
| | | auto url(get_url(URLQueryTopic)); |
| | | if (url.empty()) { |
| | | set_last_error("bus_query_topic_address url empty"); |
| | | return false; |
| | | } |
| | | |
| | | // if (remote && remote_len > 0){ |
| | | // BHAddress addr; |
| | |
| | | } |
| | | |
| | | auto url(get_url(URLQueryProcs)); |
| | | |
| | | if (url.empty()) { |
| | | set_last_error("bus_query_procs url empty"); |
| | | return false; |
| | | } |
| | | // if (remote && remote_len > 0){ |
| | | // BHAddress addr; |
| | | // if (addr.ParseFromArray(remote, remote_len)){ |
| | |
| | | string url{}; |
| | | // BHQueryTopicAddress获取proc_id |
| | | string procid{}; |
| | | if (get_proc_id_from_MsgRequestTopic(request, request_len, timeout_ms, &procid)){ |
| | | // PRNTVITAG("get_proc_id_from_MsgRequestTopic failed"); |
| | | // return false; |
| | | url = "ipc:///tmp/" + procid; |
| | | } |
| | | |
| | | if (remote && remote_len > 0){ |
| | | BHAddress addr; |
| | | if (addr.ParseFromArray(remote, remote_len)){ |
| | |
| | | // printf("======>> BHRequest use remote address %s\n", url.c_str()); |
| | | } |
| | | } |
| | | } else if (get_proc_id_from_MsgRequestTopic(request, request_len, timeout_ms, &procid)){ |
| | | // PRNTVITAG("get_proc_id_from_MsgRequestTopic failed"); |
| | | // return false; |
| | | url = "ipc:///tmp/" + procid; |
| | | } |
| | | |
| | | if (url.empty()) { |
| | | set_last_error("bus_request url empty"); |
| | | return false; |
| | | } |
| | | int rc = request2(url, request, request_len, reply, reply_len, timeout_ms); |
| | | if (rc < 0) return false; |
| | | copy_memory(proc_id, proc_id_len, procid.data(), procid.size()); |
| | |
| | | string msg; |
| | | auto ret = read_request(src, &msg, timeout_ms, &get<6>(*b)); |
| | | // printf("bus_recv_request read_request ret %d msg %s\n", ret, msg.c_str()); |
| | | if (ret != 0) return false; |
| | | if (ret < 0) return false; |
| | | |
| | | string procid{}; |
| | | if (get_proc_id_from_MsgRequestTopic(msg.data(), msg.size(), timeout_ms, &procid)){ |
| | | // PRNTVITAG("get_proc_id_from_MsgRequestTopic failed"); |
| | | // return false; |
| | | copy_memory(proc_id, proc_id_len, procid.data(), procid.size()); |
| | | if (ret == REPLY_IPC){ |
| | | string procid{}; |
| | | if (get_proc_id_from_MsgRequestTopic(msg.data(), msg.size(), timeout_ms, &procid)){ |
| | | // PRNTVITAG("get_proc_id_from_MsgRequestTopic failed"); |
| | | // return false; |
| | | copy_memory(proc_id, proc_id_len, procid.data(), procid.size()); |
| | | } |
| | | } |
| | | |
| | | copy_memory(request, request_len, msg.data(), msg.size()); |