當前位置: 首頁>>代碼示例>>Java>>正文


Java ServiceEvent.getType方法代碼示例

本文整理匯總了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);

    }
}
 
開發者ID:iilxy,項目名稱:AndroidmDNS,代碼行數:31,代碼來源:ListenerStatus.java

示例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);
    }
}
 
開發者ID:blackshadowwalker,項目名稱:log4j-collector,代碼行數:33,代碼來源:ListenerStatus.java

示例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();
}
 
開發者ID:DrivenLogic,項目名稱:droid-holiday,代碼行數:25,代碼來源:MdnsScanner.java

示例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);
    }
}
 
開發者ID:iilxy,項目名稱:AndroidmDNS,代碼行數:15,代碼來源:ListenerStatus.java

示例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);
    }
}
 
開發者ID:blackshadowwalker,項目名稱:log4j-collector,代碼行數:19,代碼來源:ListenerStatus.java

示例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);

    }
}
 
開發者ID:blackshadowwalker,項目名稱:log4j-collector,代碼行數:43,代碼來源:ListenerStatus.java

示例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);
        }
    });
}
 
開發者ID:josephw,項目名稱:jmdns,代碼行數:13,代碼來源:Browser.java

示例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();
        }
    });
}
 
開發者ID:ibaton,項目名稱:zeroconf-scanner,代碼行數:42,代碼來源:MainActivityFragment.java

示例9: generateId

import javax.jmdns.ServiceEvent; //導入方法依賴的package包/類
private static String generateId(ServiceEvent event){
    return event.getType()+event.getName();
}
 
開發者ID:ibaton,項目名稱:zeroconf-scanner,代碼行數:4,代碼來源:Scanner.java

示例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);
    }
}
 
開發者ID:iilxy,項目名稱:AndroidmDNS,代碼行數:28,代碼來源:ListenerStatus.java


注:本文中的javax.jmdns.ServiceEvent.getType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。