本文整理汇总了C#中DDS.get_subscriber方法的典型用法代码示例。如果您正苦于以下问题:C# DDS.get_subscriber方法的具体用法?C# DDS.get_subscriber怎么用?C# DDS.get_subscriber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DDS
的用法示例。
在下文中一共展示了DDS.get_subscriber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: on_data_available
// This gets called when a participant has been discovered
public override void on_data_available(DDS.DataReader reader)
{
DDS.ParticipantBuiltinTopicDataDataReader builtin_reader =
(DDS.ParticipantBuiltinTopicDataDataReader) reader;
string participant_data;
DDS.ParticipantBuiltinTopicData cur_participant_builtin_topic_data;
try {
// We only process newly seen participants
builtin_reader.take(
data_seq, info_seq,
DDS.ResourceLimitsQosPolicy.LENGTH_UNLIMITED,
DDS.SampleStateKind.ANY_SAMPLE_STATE,
DDS.ViewStateKind.NEW_VIEW_STATE,
DDS.InstanceStateKind.ANY_INSTANCE_STATE);
for (int i = 0; i < data_seq.length; ++i) {
DDS.SampleInfo info = (DDS.SampleInfo) info_seq.get_at(i);
if (info.valid_data) {
participant_data = "nil";
bool is_auth = false;
cur_participant_builtin_topic_data =
(DDS.ParticipantBuiltinTopicData)
data_seq.get_at(i);
// see if there is any participant_data
if (cur_participant_builtin_topic_data.
user_data.value.length > 0) {
participant_data =
System.Text.Encoding.ASCII.GetString(
cur_participant_builtin_topic_data.
user_data.value.buffer,
0,
cur_participant_builtin_topic_data.
user_data.value.length);
is_auth = (participant_data == auth);
}
Console.WriteLine(
"Built-in Reader: found participant \n\tkey->'" +
cur_participant_builtin_topic_data.key.GetHashCode()
+ "'\n\tuser_data->'" + participant_data + "'");
Console.WriteLine(
"instance_handle: " + info.instance_handle);
if (!is_auth) {
Console.WriteLine(
"Bad authorization, ignoring participant");
DDS.DomainParticipant participant =
reader.get_subscriber().get_participant();
DDS.InstanceHandle_t temp = info.instance_handle;
participant.ignore_participant(ref temp);
info.instance_handle = temp;
}
}
}
} catch (DDS.Retcode_NoData) {
// No data to process
// This happens when we get announcements from participants we
// already know about
return;
} finally {
builtin_reader.return_loan(data_seq, info_seq);
}
}