本文整理汇总了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()));
}
});
}