Skip to content

Commit

Permalink
fix android dns-sd subtype error, and fix manualcode code pair search… (
Browse files Browse the repository at this point in the history
#15009)

* fix android dns-sd subtype error, and fix manualcode code pair search issue

* fix restyled-io and ci errors

* using append instead of +

* added comment about this PR

* fix restyled-io and ci errors

* fix typos
  • Loading branch information
xylophone21 authored Feb 16, 2022
1 parent e05785f commit cefe25d
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,22 @@ public void publish(
String[] subTypes) {
NsdServiceInfo serviceInfo = new NsdServiceInfo();
serviceInfo.setServiceName(serviceName);
serviceInfo.setServiceType(type);

/**
* Note, subtypes registration is using an undocumented feature of android dns-sd
* service/mDNSResponder which MAY STOP WORKING in future Android versions. Here, set type =
* "${type},${subtypes1},${subtypes2},...", then subtypes1, subtypes2 etc are all registered to
* this dns-sd server, we can usd `dns-sd -B ${type},${subtypes}` or avahi-browse
* ${subtypes}._sub.${type} -r to browser it
*/
StringBuilder sb = new StringBuilder(type);
for (String subType : subTypes) {
sb.append(",").append(subType);
}
serviceInfo.setServiceType(sb.toString());

serviceInfo.setPort(port);
Log.i(TAG, "publish serviceName=" + serviceName + " type=" + type + " port=" + port);
Log.i(TAG, "publish serviceName=" + serviceName + " type=" + sb.toString() + " port=" + port);
int cnt = Math.min(textEntriesDatas.length, textEntriesKeys.length);
for (int i = 0; i < cnt; i++) {
String value = new String(textEntriesDatas[i]);
Expand Down

0 comments on commit cefe25d

Please sign in to comment.