Opensplice - Getting the nodeId in C# from a local participant

95 Views Asked by At

I am using the DCPSParticipant builtin topic to retreive infos about participants on the domain (I'm working with C#).

In the example, the sample received contains the node identification which can be accessed with :

int nodeId = data[i].Key[0];

Now, I'd like to get the same ID but from a locally created participant. The goal is to correlate a local participant with a ParticipantBuiltInTopicData.

In RTI, we can get the GUID of a participant through its instance handle (see this post), however I can't manage to replicate it in C#.

How can I get the nodeID from a local participant ?

Alternatively, can I get the GUID of a local participant ?

1

There are 1 best solutions below

0
On

I found a way to do it, though it seems a bit odd.

After creating the local participant, I'm calling the GetDiscoveredParticipantData using the local participant instanceHandle.

IDomainParticipant participant = DomainParticipantFactory.Instance.CreateParticipant(DomainId.Default);
InstanceHandle handle = participant.InstanceHandle;
ParticipantBuiltinTopicData selfData = new ParticipantBuiltinTopicData();

participant.GetDiscoveredParticipantData(ref selfData, handle);
Console.WriteLine(selfData.Key[0]); // Node id