| | |
| | | while (true) { |
| | | for(auto && i : topics){ |
| | | auto msg = base_msg + "test_ps pub message "+i+"-->msg-"+to_string(count++); |
| | | MsgPublish pbmsg; |
| | | pbmsg.set_topic(i); |
| | | pbmsg.set_data(msg); |
| | | auto data = pbmsg.SerializeAsString(); |
| | | // TestPub(i.c_str(), i.length(), data.c_str(), data.length()); |
| | | int pubres = bus_client_pubmsg(handle, (void*)data.data(), data.size()); |
| | | printf("======>> bus_client_pubmsg [%s]\n", msg.c_str()); |
| | | // MsgPublish pbmsg; |
| | | // pbmsg.set_topic(i); |
| | | // pbmsg.set_data(msg); |
| | | // auto data = pbmsg.SerializeAsString(); |
| | | // int ret = bus_client_pubmsg(handle, data.data(), data.size()); |
| | | |
| | | int ret = bus_client_publish(handle, i.data(), i.size(), msg.data(), msg.size()); |
| | | printf("======>> bus_client_pubmsg [%s] ret %d\n", msg.c_str(), ret); |
| | | this_thread::sleep_for(chrono::seconds{2}); |
| | | } |
| | | } |