void ReqRepHelloWorldRequester::init() { ParticipantAttributes pattr; pattr.rtps.builtin.domainId = (uint32_t)boost::interprocess::ipcdetail::get_current_process_id() % 230; participant_ = Domain::createParticipant(pattr); ASSERT_NE(participant_, nullptr); // Register type ASSERT_EQ(Domain::registerType(participant_,&type_), true); //Create subscriber sattr.topic.topicKind = NO_KEY; sattr.topic.topicDataType = "HelloWorldType"; configSubscriber("Reply"); reply_subscriber_ = Domain::createSubscriber(participant_, sattr, &reply_listener_); ASSERT_NE(reply_subscriber_, nullptr); //Create publisher puattr.topic.topicKind = NO_KEY; puattr.topic.topicDataType = "HelloWorldType"; configPublisher("Request"); request_publisher_ = Domain::createPublisher(participant_, puattr, &request_listener_); ASSERT_NE(request_publisher_, nullptr); initialized_ = true; }
// TODO Change api of set_IP4_address to support const string. void PubSubHelloWorldReader::init(uint16_t nmsgs) { ParticipantAttributes pattr; participant_ = Domain::createParticipant(pattr); ASSERT_NE(participant_, nullptr); // Register type ASSERT_EQ(Domain::registerType(participant_,&type_), true); //Create subscriber SubscriberAttributes sattr; sattr.topic.topicKind = NO_KEY; sattr.topic.topicDataType = "HelloWorldType"; sattr.topic.topicName = "HelloWorldTopic"; configSubscriber(sattr); subscriber_ = Domain::createSubscriber(participant_, sattr, &listener_); ASSERT_NE(subscriber_, nullptr); // Initialize list of msgs for(uint16_t count = 0; count < nmsgs; ++count) { msgs_.push_back(count); } initialized_ = true; }