| | |
| | | } |
| | | |
| | | 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>(); |
| | | |
| | |
| | | { |
| | | 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; |
| | | } |
| | |
| | | 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(); |
| | | } |
| | |
| | | return !rep->msg_.empty(); |
| | | }); |
| | | if (!status){ |
| | | PRNTVITAG("subscribe_read timeout"); |
| | | PRNTVITAG("read_request timeout"); |
| | | return -1; |
| | | } |
| | | auto iter = rep->msg_.begin(); |