本文整理汇总了C++中DomainParticipant_var::delete_subscriber方法的典型用法代码示例。如果您正苦于以下问题:C++ DomainParticipant_var::delete_subscriber方法的具体用法?C++ DomainParticipant_var::delete_subscriber怎么用?C++ DomainParticipant_var::delete_subscriber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomainParticipant_var
的用法示例。
在下文中一共展示了DomainParticipant_var::delete_subscriber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ChatMessageSeq
//.........这里部分代码省略.........
participant.in(),
chatMessageTypeName);
checkStatus(status, "NetworkPartitionsData::ChatMessageTypeSupport::register_type");
/* Set the ReliabilityQosPolicy to RELIABLE. */
status = participant->get_default_topic_qos(reliable_topic_qos);
checkStatus(status, "DDS::DomainParticipant::get_default_topic_qos");
reliable_topic_qos.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS;
/* Make the tailored QoS the new default. */
status = participant->set_default_topic_qos(reliable_topic_qos);
checkStatus(status, "DDS::DomainParticipant::set_default_topic_qos");
/* Use the changed policy when defining the ChatMessage topic */
chatMessageTopic = participant->create_topic(
"Chat_ChatMessage",
chatMessageTypeName,
reliable_topic_qos,
NULL,
STATUS_MASK_NONE);
checkHandle(chatMessageTopic.in(), "DDS::DomainParticipant::create_topic (ChatMessage)");
/* Adapt the default SubscriberQos to read from the "ChatRoom1" Partition. */
status = participant->get_default_subscriber_qos (sub_qos);
checkStatus(status, "DDS::DomainParticipant::get_default_subscriber_qos");
sub_qos.partition.name.length(1);
sub_qos.partition.name[0] = partitionName;
/* Create a Subscriber for the MessageBoard application. */
chatSubscriber = participant->create_subscriber(sub_qos, NULL, STATUS_MASK_NONE);
checkHandle(chatSubscriber.in(), "DDS::DomainParticipant::create_subscriber");
/* Create a DataReader for the NamedMessage Topic (using the appropriate QoS). */
parentReader = chatSubscriber->create_datareader(
chatMessageTopic.in(),
DATAREADER_QOS_USE_TOPIC_QOS,
NULL,
STATUS_MASK_NONE);
checkHandle(parentReader, "DDS::Subscriber::create_datareader");
/* Narrow the abstract parent into its typed representative. */
chatAdmin = ChatMessageDataReader::_narrow(parentReader);
checkHandle(chatAdmin.in(), "NetworkPartitionsData::ChatMessageDataReader::_narrow");
/* Print a message that the MessageBoard has opened. */
cout << "MessageBoard has opened: send a ChatMessage with userID = -1 to close it...." << endl << endl;
while (!terminated) {
/* Note: using read does not remove the samples from
unregistered instances from the DataReader. This means
that the DataRase would use more and more resources.
That's why we use take here instead. */
status = chatAdmin->take(
msgSeq,
infoSeq,
LENGTH_UNLIMITED,
ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ALIVE_INSTANCE_STATE );
checkStatus(status, "NetworkPartitionsData::ChatMessageDataReader::take");
for (ULong i = 0; i < msgSeq->length(); i++) {
ChatMessage *msg = &(msgSeq[i]);
if (msg->userID == TERMINATION_MESSAGE) {
cout << "Termination message received: exiting..." << endl;
terminated = true;
} else {
cout << msg->userID << ": " << msg->content << endl;
}
}
status = chatAdmin->return_loan(msgSeq, infoSeq);
checkStatus(status, "NetworkPartitionsData::ChatMessageDataReader::return_loan");
/* Sleep for some amount of time, so as not to consume too many CPU cycles. */
sleep(1);
}
/* Remove the DataReader */
status = chatSubscriber->delete_datareader(chatAdmin.in());
checkStatus(status, "DDS::Subscriber::delete_datareader");
/* Remove the Subscriber. */
status = participant->delete_subscriber(chatSubscriber.in());
checkStatus(status, "DDS::DomainParticipant::delete_subscriber");
/* Remove the Topic. */
status = participant->delete_topic(chatMessageTopic.in());
checkStatus(status, "DDS::DomainParticipant::delete_topic (chatMessageTopic)");
/* De-allocate the type-names. */
string_free(chatMessageTypeName);
/* Remove the DomainParticipant. */
status = dpf->delete_participant(participant.in());
checkStatus(status, "DDS::DomainParticipantFactory::delete_participant");
return 0;
}