本文整理汇总了Java中javax.jmdns.ServiceEvent.getType方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceEvent.getType方法的具体用法?Java ServiceEvent.getType怎么用?Java ServiceEvent.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jmdns.ServiceEvent
的用法示例。
在下文中一共展示了ServiceEvent.getType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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包/类
/**
* 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);
}
}
示例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: 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);
}
}
示例7: serviceTypeAdded
import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
@Override
public void serviceTypeAdded(ServiceEvent event) {
final String aType = event.getType();
System.out.println("TYPE: " + aType);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
insertSorted(types, aType);
}
});
}
示例8: setEvent
import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
public void setEvent(final ServiceEvent serviceEvent){
lblServiceName.setText(serviceEvent.getName());
String serviceType = serviceEvent.getType();
String[] typePath = serviceType.split("\\.");
if(typePath.length > 0){
serviceType = typePath[0].replace("_"," ").trim();
}
lblServiceType.setText(serviceType);
if(lblServiceServer != null) lblServiceServer.setText(serviceEvent.getInfo().getURLs()[0]);
if(lblServiceApplication != null) lblServiceApplication.setText(serviceEvent.getInfo().getServer() + ":" + serviceEvent.getInfo().getPort());
if(louProperty != null){
louProperty.removeAllViews();
Enumeration<String> propertyIterator = serviceEvent.getInfo().getPropertyNames();
while(propertyIterator.hasMoreElements()){
String key = propertyIterator.nextElement();
String value = serviceEvent.getInfo().getPropertyString(key);
LayoutInflater inflater = LayoutInflater.from(getContext());
View propertyItem = inflater.inflate(R.layout.item_property, louProperty, false);
TextView lblProperty = (TextView) propertyItem.findViewById(R.id.lbl_property);
lblProperty.setText(Html.fromHtml(getString(R.string.property, key, value)));
louProperty.addView(propertyItem);
}
}
itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(selectedService == serviceEvent) {
selectedService = null;
} else {
selectedService = serviceEvent;
}
notifyDataSetChanged();
}
});
}
示例9: generateId
import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
private static String generateId(ServiceEvent event){
return event.getType()+event.getName();
}
示例10: 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);
}
}