本文整理汇总了Java中javax.jmdns.ServiceEvent.getName方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceEvent.getName方法的具体用法?Java ServiceEvent.getName怎么用?Java ServiceEvent.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jmdns.ServiceEvent
的用法示例。
在下文中一共展示了ServiceEvent.getName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: serviceResolved
import javax.jmdns.ServiceEvent; //导入方法依赖的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);
}
}
示例2: serviceAdded
import javax.jmdns.ServiceEvent; //导入方法依赖的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);
}
}
示例3: serviceAdded
import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
@Override
public void serviceAdded(final ServiceEvent event) {
log.info("Service added Called - Requesting service info");
final String type = event.getType();
final String name = event.getName();
log.info("Service added: type= " + type + ", name: " + name);
Thread thread = new Thread() {
@Override
public void run() {
try {
// needs to be in it's own thread as it blocks
log.info("Service added: Requesting service info");
jmdns.requestServiceInfo(type, name);
}
catch (Throwable ex) {
ex.printStackTrace();
log.error("Error requesting service info", ex);
}
}
};
thread.start();
}
示例4: serviceRemoved
import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
@Override
public void serviceRemoved(ServiceEvent event) {
final String name = event.getName();
final ServiceInfo service_info = event.getInfo();
ZeroconfDiscoveryHandler callback = listener_callbacks.get(service_info.getType());
if ( callback != null ) {
callback.serviceRemoved(toDiscoveredService(service_info));
} else {
logger.println("[-] Service : " + name);
}
}
示例5: serviceRemoved
import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
/**
* A service has been removed.
*
* @param event
* The ServiceEvent providing the name and fully qualified type of the service.
*/
void serviceRemoved(ServiceEvent event) {
String qualifiedName = event.getName() + "." + event.getType();
if (_addedServices.remove(qualifiedName, _addedServices.get(qualifiedName))) {
this.getListener().serviceRemoved(event);
} else {
logger.finer("Service Removed called for a service already removed: " + event);
}
}
示例6: serviceRemoved
import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
/**
* A service has been removed.
*
* @param event
* The ServiceEvent providing the name and fully qualified type of the service.
*/
void serviceRemoved(ServiceEvent event)
{
String qualifiedName = event.getName() + "." + event.getType();
if (_addedServices.remove(qualifiedName, _addedServices.get(qualifiedName)))
{
this.getListener().serviceRemoved(event);
}
else
{
logger.finer("Service Removed called for a service already removed: " + event);
}
}
示例7: serviceResolved
import javax.jmdns.ServiceEvent; //导入方法依赖的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.ServiceEvent; //导入方法依赖的package包/类
@Override
public void serviceAdded(ServiceEvent event) {
final String name = event.getName();
System.out.println("ADD: " + name);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
insertSorted(services, name);
}
});
}
示例9: serviceRemoved
import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
@Override
public void serviceRemoved(ServiceEvent event) {
final String name = event.getName();
System.out.println("REMOVE: " + name);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
services.removeElement(name);
}
});
}
示例10: serviceResolved
import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
@Override
public void serviceResolved(ServiceEvent event) {
final String name = event.getName();
System.out.println("RESOLVED: " + name);
if (name.equals(serviceList.getSelectedValue())) {
ServiceInfo[] serviceInfos = this.jmmdns.getServiceInfos(type, name);
this.dislayInfo(serviceInfos);
// this.dislayInfo(new ServiceInfo[] { event.getInfo() });
}
}
示例11: generateId
import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
private static String generateId(ServiceEvent event){
return event.getType()+event.getName();
}
示例12: serviceAdded
import javax.jmdns.ServiceEvent; //导入方法依赖的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);
}
}