zhangmeng
2021-12-13 a884637d0376d469ee307ebe1d117ae908a4c340
src/bn_api.cpp
@@ -176,7 +176,19 @@
{
    if (!topic || topic_len <= 0) return false;
    return simple_request(get_url(URLQueryTopic), topic, topic_len, reply, reply_len, timeout_ms);
    auto url(get_url(URLQueryTopic));
    if (remote && remote_len > 0){
        BHAddress addr;
        if (addr.ParseFromArray(remote, remote_len)){
            if (!addr.ip().empty() && addr.port() > 0){
                // url = "tcp://" + addr.ip() + ":" + to_string(addr.port());
                printf("======>> BHQueryTopicAddress use remote address %s\n", url.c_str());
            }
        }
    }
    return simple_request(url, topic, topic_len, reply, reply_len, timeout_ms);
}
// 请求在线进程 request
@@ -190,9 +202,19 @@
{
    if (!query || query_len <= 0) return false;
    auto ret = simple_request(get_url(URLQueryProcs), query, query_len, reply, reply_len, timeout_ms);
    // printf("======>> BHQueryProcs *reply %p reply_len %d\n", *reply, *reply_len);
    return ret;
    auto url(get_url(URLQueryProcs));
    if (remote && remote_len > 0){
        BHAddress addr;
        if (addr.ParseFromArray(remote, remote_len)){
            if (!addr.ip().empty() && addr.port() > 0){
                // url = "tcp://" + addr.ip() + ":" + to_string(addr.port());
                printf("======>> BHQueryProcs use remote address %s\n", url.c_str());
            }
        }
    }
    return simple_request(url, query, query_len, reply, reply_len, timeout_ms);
}
// above communicate with center
@@ -352,11 +374,13 @@
    auto url("ipc:///tmp/" + procid);
    BHAddress addr;
    if (addr.ParseFromArray(remote, remote_len)){
        if (!addr.ip().empty() && addr.port() > 0){
            url = "tcp://" + addr.ip() + ":" + to_string(addr.port());
            printf("======>>use remote address %s\n", url.c_str());
    if (remote && remote_len > 0){
        BHAddress addr;
        if (addr.ParseFromArray(remote, remote_len)){
            if (!addr.ip().empty() && addr.port() > 0){
                url = "tcp://" + addr.ip() + ":" + to_string(addr.port());
                printf("======>> BHRequest use remote address %s\n", url.c_str());
            }
        }
    }
    // 使用procid作为ipc通信