Scan for publishers?

9 posts / 0 new
Last post
Offline
Last seen: 5 months 4 days ago
Joined: 05/13/2023
Posts: 12
Scan for publishers?

Hello, just getting started with C# and RTI connext, just created my first application that publishes and subsribes.  Pretty excited about that :)

I was curious... are there functions in Connext through which, from my C# application, I can scan to get a list of published topics on a given domain?

Thanks!

PK_RTI's picture
Offline
Last seen: 2 months 2 days ago
Joined: 07/01/2021
Posts: 27

I think that this how to on Builtin Topics https://community.rti.com/examples/builtin-topics is what you are looking for. If it's not, let us know.

PK_RTI's picture
Offline
Last seen: 2 months 2 days ago
Joined: 07/01/2021
Posts: 27

A wiser colleague than I pointed out that you may be looking for the lighter-weight C# API that does exactly what you asked for:

https://community.rti.com/static/documentation/connext-dds/6.1.1/doc/api/connext_dds/api_csharp/class_rti_1_1_dds_1_1_domain_1_1_domain_participant.html#a98eee0210a6a4d41cca5e90e14954f22

Offline
Last seen: 5 months 4 days ago
Joined: 05/13/2023
Posts: 12

Thank you. I'm trying to figure out how to use that though... I don't suppose you know of some example code so that I can borrow the syntax?  I searched on the entire examples library and no hits.  

Offline
Last seen: 5 months 4 days ago
Joined: 05/13/2023
Posts: 12

Also, it seems that after I create a participant and retrieve "DiscoveredTopics" from it, it seems to return a collection with the correct number of handles (ie it varies with the number of published topics I have running).

Howeve when I take a handle and pass it into participant.GetDiscoveredTopicData(h) (as is indicated by the doc in order to use the handles), I get a "NotSupportdException" exception with a blank message. 

Any idea what would cause that exception?

Thanks.

Offline
Last seen: 5 months 4 days ago
Joined: 05/13/2023
Posts: 12

In case it clarifies, here is the code.  The first count reports the right number of topics currently being published, but when I try to run GetDiscoveredTopicData on the returned handles, I get the aforementioned exception.

Thanks.

 

code 

public static void GetDiscoverable(int domainId)
{
using DomainParticipant participant = DomainParticipantFactory.Instance.CreateParticipant(domainId);

var ts = participant.DiscoveredTopics;

Debug.Print("count = " + ts.Count().ToString());

foreach (var th in ts)
{
var data = participant.GetDiscoveredTopicData(th);  // <-- exception happens here
Debug.Print(data.ToString());

}
}

 

Howard's picture
Offline
Last seen: 1 day 13 hours ago
Joined: 11/29/2012
Posts: 565

Unfortunately, this won't work how you want it to work.

Per documentation: "This call is not supported for remote topics. If a remote topic_handle is used, the operation will fail with DDS_RETCODE_UNSUPPORTED."

But what you want to know is about the remote topics that are discovered.

Which means you'll have to implement something that uses the DDS Builtin-topics to monitor and cache the discovery info per the link in PK's original posting: https://community.rti.com/comment/7232#comment-7232

 

Offline
Last seen: 5 months 4 days ago
Joined: 05/13/2023
Posts: 12

Thanks.  However, you say "per the link in the original posting"... that link only leads to a very terse doc entry on "DiscoveredTopics", unless it goes somewhere different for you.

Is there example code anywhere for what you're describing?

 

PK_RTI's picture
Offline
Last seen: 2 months 2 days ago
Joined: 07/01/2021
Posts: 27

You may have looked at the second response, pointing to the API in the C# Manual.

The initial response references the Builtin Topic functionality https://community.rti.com/examples/builtin-topics . There is a C# example in that how to (along with other languages).