本文整理汇总了Java中javax.jmdns.ServiceInfo.hasData方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceInfo.hasData方法的具体用法?Java ServiceInfo.hasData怎么用?Java ServiceInfo.hasData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jmdns.ServiceInfo
的用法示例。
在下文中一共展示了ServiceInfo.hasData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitForInfoData
import javax.jmdns.ServiceInfo; //导入方法依赖的package包/类
private void waitForInfoData(ServiceInfo info, long timeout) {
synchronized (info) {
long loops = (timeout / 200L);
if (loops < 1) {
loops = 1;
}
for (int i = 0; i < loops; i++) {
if (info.hasData()) {
break;
}
try {
info.wait(200);
} catch (final InterruptedException e) {
/* Stub */
}
}
}
}
示例2: serviceAdded
import javax.jmdns.ServiceInfo; //导入方法依赖的package包/类
/**
* A service has been added.
*
* @param event
* service event
*/
@Override
public void serviceAdded(ServiceEvent event) {
synchronized (this) {
ServiceInfo info = event.getInfo();
if ((info != null) && (info.hasData())) {
_infos.put(event.getName(), info);
} else {
String subtype = (info != null ? info.getSubtype() : "");
info = ((JmDNSImpl) event.getDNS()).resolveServiceInfo(event.getType(), event.getName(), subtype, true);
if (info != null) {
_infos.put(event.getName(), info);
} else {
_events.put(event.getName(), event);
}
}
}
}
示例3: serviceResolved
import javax.jmdns.ServiceInfo; //导入方法依赖的package包/类
/**
* A service has been resolved. Its details are now available in the ServiceInfo record.<br/>
* <b>Note:</b>This call back will never be called if the service does not resolve.<br/>
*
* @param event
* The ServiceEvent providing the name, the fully qualified type of the service, and the service info record.
*/
synchronized void serviceResolved(ServiceEvent event) {
ServiceInfo info = event.getInfo();
if ((info != null) && (info.hasData())) {
String qualifiedName = event.getName() + "." + event.getType();
ServiceInfo previousServiceInfo = _addedServices.get(qualifiedName);
if (!_sameInfo(info, previousServiceInfo)) {
if (null == previousServiceInfo) {
if (null == _addedServices.putIfAbsent(qualifiedName, info.clone())) {
this.getListener().serviceResolved(event);
}
} else {
if (_addedServices.replace(qualifiedName, previousServiceInfo, info.clone())) {
this.getListener().serviceResolved(event);
}
}
} else {
logger.finer("Service Resolved called for a service already resolved: " + event);
}
} else {
logger.warning("Service Resolved called for an unresolved event: " + event);
}
}
示例4: waitForInfoData
import javax.jmdns.ServiceInfo; //导入方法依赖的package包/类
private void waitForInfoData(ServiceInfo info, long timeout)
{
synchronized (info)
{
long loops = (timeout / 200L);
if (loops < 1)
{
loops = 1;
}
for (int i = 0; i < loops; i++)
{
if (info.hasData())
{
break;
}
try
{
info.wait(200);
}
catch (final InterruptedException e)
{
/* Stub */
}
}
}
}
示例5: serviceAdded
import javax.jmdns.ServiceInfo; //导入方法依赖的package包/类
/**
* A service has been added.
*
* @param event
* service event
*/
@Override
public void serviceAdded(ServiceEvent event)
{
synchronized (this)
{
ServiceInfo info = event.getInfo();
if ((info != null) && (info.hasData()))
{
_infos.put(event.getName(), info);
}
else
{
String subtype = (info != null ? info.getSubtype() : "");
info = ((JmDNSImpl) event.getDNS()).resolveServiceInfo(event.getType(), event.getName(), subtype, true);
if (info != null)
{
_infos.put(event.getName(), info);
}
else
{
_events.put(event.getName(), event);
}
}
}
}
示例6: serviceAdded
import javax.jmdns.ServiceInfo; //导入方法依赖的package包/类
/**
* A service has been added.<br/>
* <b>Note:</b>This event is only the service added event. The service info associated with this event does not include resolution information.<br/>
* To get the full resolved information you need to listen to {@link #serviceResolved(javax.jmdns.ServiceEvent)} or call {@link javax.jmdns.JmDNS#getServiceInfo(String, String, long)}
*
* <pre>
* ServiceInfo info = event.getDNS().getServiceInfo(event.getType(), event.getName())
* </pre>
* <p>
* Please note that service resolution may take a few second to resolve.
* </p>
*
* @param event
* The ServiceEvent providing the name and fully qualified type of the service.
*/
void serviceAdded(ServiceEvent event)
{
String qualifiedName = event.getName() + "." + event.getType();
if (null == _addedServices.putIfAbsent(qualifiedName, (ServiceInfo) event.getInfo().clone()))
{
this.getListener().serviceAdded(event);
ServiceInfo info = event.getInfo();
if ((info != null) && (info.hasData()))
{
this.getListener().serviceResolved(event);
}
}
else
{
logger.finer("Service Added called for a service already added: " + event);
}
}
示例7: serviceResolved
import javax.jmdns.ServiceInfo; //导入方法依赖的package包/类
/**
* A service has been resolved. Its details are now available in the ServiceInfo record.<br/>
* <b>Note:</b>This call back will never be called if the service does not resolve.<br/>
*
* @param event
* The ServiceEvent providing the name, the fully qualified type of the service, and the service info record.
*/
synchronized void serviceResolved(ServiceEvent event)
{
ServiceInfo info = event.getInfo();
if ((info != null) && (info.hasData()))
{
String qualifiedName = event.getName() + "." + event.getType();
ServiceInfo previousServiceInfo = _addedServices.get(qualifiedName);
if (!_sameInfo(info, previousServiceInfo))
{
if (null == previousServiceInfo)
{
if (null == _addedServices.putIfAbsent(qualifiedName, (ServiceInfo) info.clone()))
{
this.getListener().serviceResolved(event);
}
}
else
{
if (_addedServices.replace(qualifiedName, previousServiceInfo, (ServiceInfo) info.clone()))
{
this.getListener().serviceResolved(event);
}
}
}
else
{
logger.finer("Service Resolved called for a service already resolved: " + event);
}
}
else
{
logger.warning("Service Resolved called for an unresolved event: " + event);
}
}
示例8: serviceAdded
import javax.jmdns.ServiceInfo; //导入方法依赖的package包/类
/**
* A service has been added.<br/>
* <b>Note:</b>This event is only the service added event. The service info associated with this event does not include resolution information.<br/>
* To get the full resolved information you need to listen to {@link #serviceResolved(ServiceEvent)} or call {@link JmDNS#getServiceInfo(String, String, long)}
*
* <pre>
* ServiceInfo info = event.getDNS().getServiceInfo(event.getType(), event.getName())
* </pre>
* <p>
* Please note that service resolution may take a few second to resolve.
* </p>
*
* @param event
* The ServiceEvent providing the name and fully qualified type of the service.
*/
void serviceAdded(ServiceEvent event) {
String qualifiedName = event.getName() + "." + event.getType();
if (null == _addedServices.putIfAbsent(qualifiedName, event.getInfo().clone())) {
this.getListener().serviceAdded(event);
ServiceInfo info = event.getInfo();
if ((info != null) && (info.hasData())) {
this.getListener().serviceResolved(event);
}
} else {
logger.finer("Service Added called for a service already added: " + event);
}
}