unable to get txtrecords from ServiceEvent in the function serviceAdded (From JmDNS)

StackOverflow https://stackoverflow.com/questions/12401822

  •  01-07-2021
  •  | 
  •  

Pregunta

I 'm unable to get txtrecord from ServiceEvent in the function serviceAdded (From JmDNS).

but I m able to get txtrecord from ServiceEvent in the function serviceResolved

The serviceResolved is executed at the start-up only 1 time and does not capte all services.

The serviceAdded is execute each time it capte a new service. but when trying to access to txtrecord, I found nothing in txtrecord I found only the service name.

are there a solution to get all txtRecord each time I capte a new service ?

¿Fue útil?

Solución

The service info associated with the event of serviceAdded method does not include resolution information. To get the full resolved information we need to call JmDNS.getServiceInfo(String, String, long)

public void serviceAdded(ServiceEvent event) {
                   ServiceInfo inf = event.getDNS().getServiceInfo(event.getType(), event.getName());
               }

Reference: http://jmdns.sourceforge.net/apidocs/javax/jmdns/ServiceListener.html

Otros consejos

Also can be done by

 public void serviceAdded(ServiceEvent event) {
                event.getDNS().requestServiceInfo(event.getType(), event.getName(), true);
 }

This will request for service resolution.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top