本文整理匯總了Java中javax.jmdns.ServiceInfo.getInetAddresses方法的典型用法代碼示例。如果您正苦於以下問題:Java ServiceInfo.getInetAddresses方法的具體用法?Java ServiceInfo.getInetAddresses怎麽用?Java ServiceInfo.getInetAddresses使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jmdns.ServiceInfo
的用法示例。
在下文中一共展示了ServiceInfo.getInetAddresses方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: serviceResolved
import javax.jmdns.ServiceInfo; //導入方法依賴的package包/類
@Override
/**
* This implements service resolved in a very simple way. If the user has callbacks, then
* it just directly resolves the service info to a ros service info. Note that if you have
* multiple interfaces (e.g. eth0, wlan0) then this won't provide the resolved artifact
* for all interfaces. It might be worth adding a check for that service across all
* interfaces here and providing a fully updated (with regards to addresses) ros
* service info artifact to the user's callback here.
*/
public void serviceResolved(ServiceEvent event) {
final ServiceInfo service_info = event.getInfo();
ZeroconfDiscoveryHandler callback = listener_callbacks.get(service_info.getType());
if ( callback != null ) {
callback.serviceResolved(toDiscoveredService(service_info));
} else {
logger.println("[=] Resolved : " + service_info.getQualifiedName());
logger.println(" Port : " + service_info.getPort() );
for ( int i = 0; i < service_info.getInetAddresses().length; ++i ) {
logger.println(" Address : " + service_info.getInetAddresses()[i].getHostAddress() );
}
}
}
示例2: onDiscoveredService
import javax.jmdns.ServiceInfo; //導入方法依賴的package包/類
private void onDiscoveredService(final ServiceInfo info) {
if (info.getInetAddresses() == null) {
return;
}
final WlanAddress address = new WlanAddress(this.dispatcher, info.getInetAddresses()[0], info.getPort());
this.addresses.put(info.getName(), address);
this.executor.execute(new Runnable() {
public void run() {
WlanBrowser.this.handler.onAddressDiscovered(WlanBrowser.this, address, UUID.fromString(info.getName()));
}
});
}