当前位置: 首页>>代码示例>>C#>>正文


C# DDS.get_subscriber方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:hakiri,项目名称:rticonnextdds-examples,代码行数:69,代码来源:msg_publisher.cs


注:本文中的DDS.get_subscriber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。