zhangmeng
2022-01-18 131892668a0eb8073f00d0f35f2295e03c357130
src/nng_wrap.cpp
@@ -162,6 +162,7 @@
}
int publish(const std::string& topic, const void* data, const int data_len, void* arg/*=NULL*/){
    // printf("======>> publish topic %s\n", topic.c_str());
    _ps* pub = (_ps*)arg;
    if (!pub) pub = singleton<_ps>();
@@ -209,12 +210,12 @@
            if (m_len > 0){
                string tmp_msg{m, (size_t)m_len};
                nn_freemsg(m);
                auto topic{tmp_msg.c_str()};
                const auto topic{tmp_msg.c_str()};
                string msg{};
                {
                    lock_guard<mutex> l{(*sub)()};
                    for(auto && i : sub->topics_){
                        if (i.compare(topic) == 0){
                        if (!!!i.compare(topic)){
                            msg = move(tmp_msg.substr(i.size()+1));
                            break;
                        }
@@ -512,6 +513,7 @@
        get<1>(get<1>(rep->socks_)) = port;
        ipc = "tcp://0.0.0.0:" + to_string(port);
        if(create_server(&get<0>(get<1>(rep->socks_)), ipc, 62, rep) != 0) return -1;
        printf("======>> create server for remote port %d\n", port);
    }else {
        get<0>(get<1>(rep->socks_)).id = numeric_limits<int32_t>::max();
    }
@@ -564,7 +566,7 @@
            return !rep->msg_.empty();
        });
        if (!status){
            PRNTVITAG("subscribe_read timeout");
            PRNTVITAG("read_request timeout");
            return -1;
        }
        auto iter = rep->msg_.begin();