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!
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.
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
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.
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.
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());
}
}
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
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?
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).