AllJoyn: Get well-known name from announced About message?

81 views Asked by At

Is it possible in AllJoyn to get the well-known name of a remote device from its announced About message? I would like to use the well-known name to connect to the device later on without a new discovery process.

I know I can get the device ID from the About message, but the well-known name seems to be different:

DeviceID: 558591fa-97db-464f-a8fa-efa30ecacc17

Actual Well-known name: net.allplay.MediaPlayer.i558591fa-97db-464f-a8fa-efa30ecacc17.r3X5_6mxu

While I could hard-code the beginning, I cannot find the last part (r3X5_6mxu) in the About message. Am I looking in the wrong place or is this information just not available?

1

There are 1 answers

0
P. Sigurdson On BEST ANSWER

Not from the announced About message.

When your app receives an announcement, your registered AboutListener's announced() method is called:

announced(String busName, int version, short port,
        AboutObjectDescription[] objectDescriptions, Map<String, Variant> aboutData)

The busName parameter is mentioned in the javadoc as being the well-known name of the remote attachment, but in my experience the busName value has been the remote attachment's unique name. And the aboutData Map parameter does not contain the well-know name nor the unique name of the remote attachment (as far as standard fields in the aboutData map are concerned).

However, if you wish to correlate the remote attachment's well-known to its unique name (assuming a well-known name is published), then perhaps you could implement the BusListener interface and register it on your local bus. Each time the remote attachment has a name change, the following BusListener method is called in your app:

nameOwnerChanged(String busName, String previousOwner, String newOwner)

The busName parameter can be the remote attachment's well-known name (if it has one, otherwise it will be its unique name). For example, when the remote attachment is first established and assigned a name, a nameOwnerChanged message is sent (received by your app) with previousOwner=NULL and newOwner=[UniqueName]. Or when the remote attachment is terminated, for example, a nameOwnerChanged message is sent with previousOwner=[UniqueName] and newOwner=NULL. In this way you can see the remote attachment's busName and associated newOwner value.

Register interest in listening for remote well-known name prefix by calling findAdvertisedName(String namePrefix) on your local BusAttachment.