当前位置: 首页>>代码示例>>Java>>正文


Java ServiceEvent.getInfo方法代码示例

本文整理汇总了Java中javax.jmdns.ServiceEvent.getInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceEvent.getInfo方法的具体用法?Java ServiceEvent.getInfo怎么用?Java ServiceEvent.getInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jmdns.ServiceEvent的用法示例。


在下文中一共展示了ServiceEvent.getInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: serviceRemoved

import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
@Override
public void serviceRemoved(ServiceEvent event) {
	if (event.getInfo() == null) {
		// silent
		return;
	}
	String name = event.getInfo().getName();
	if (StringUtils.isEmpty(name)) {
		name = renderer.getConfName();
	}
	ArrayList<ChromeDevice> devices = new ArrayList<>();
	for (ChromeDevice device : chromeCasts) {
		if (name.equals(device.getRendererName())) {
			// Make the icon grey and delete after 5 seconds
			device.delete(5000);
			LOGGER.debug("Chromecast \"{}\" is gone.", name);
			continue;
		}
		devices.add(device);
	}
	chromeCasts = devices;
}
 
开发者ID:DigitalMediaServer,项目名称:DigitalMediaServer,代码行数:23,代码来源:ChromecastMgr.java

示例2: serviceResolved

import javax.jmdns.ServiceEvent; //导入方法依赖的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() );
        }
    }
}
 
开发者ID:rosalfred,项目名称:smarthome_network_zeroconf,代码行数:23,代码来源:Zeroconf.java

示例3: handleServiceResolved

import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
void handleServiceResolved(ServiceEvent event) {
    List<ServiceListenerStatus> list = _serviceListeners.get(event.getType().toLowerCase());
    final List<ServiceListenerStatus> listCopy;
    if ((list != null) && (!list.isEmpty())) {
        if ((event.getInfo() != null) && event.getInfo().hasData()) {
            final ServiceEvent localEvent = event;
            synchronized (list) {
                listCopy = new ArrayList<ServiceListenerStatus>(list);
            }
            for (final ServiceListenerStatus listener : listCopy) {
                _executor.submit(new Runnable() {
                    /** {@inheritDoc} */
                    @Override
                    public void run() {
                        listener.serviceResolved(localEvent);
                    }
                });
            }
        }
    }
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:22,代码来源:JmDNSImpl.java

示例4: serviceAdded

import javax.jmdns.ServiceEvent; //导入方法依赖的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);
            }
        }
    }
}
 
开发者ID:iilxy,项目名称:AndroidmDNS,代码行数:24,代码来源:JmDNSImpl.java

示例5: 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

示例6: serviceAdded

import javax.jmdns.ServiceEvent; //导入方法依赖的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);
            }
        }
    }
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:32,代码来源:JmDNSImpl.java

示例7: 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

示例8: serviceRemoved

import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
@Override
public void serviceRemoved ( ServiceEvent event )
{
    Log.d ( TAG, "Service Removed: " + event.getInfo ().getName () );
    final ServiceInfo i = event.getInfo ();

    runOnUiThread (
            new Runnable ()
            {
                @Override
                public void run ()
                {
                    m_adapter.remove ( i );
                }
            }
    );
}
 
开发者ID:arfbtwn,项目名称:MPRIS2-Remote,代码行数:18,代码来源:SelectServer.java

示例9: serviceResolved

import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
@Override
public void serviceResolved ( ServiceEvent event )
{
    Log.d ( TAG, "Service Resolved: " + event.getInfo ().getName () );
    final ServiceInfo i = event.getInfo ();

    runOnUiThread (
            new Runnable ()
            {
                @Override
                public void run ()
                {
                    m_adapter.add ( i );
                }
            }
    );
}
 
开发者ID:arfbtwn,项目名称:MPRIS2-Remote,代码行数:18,代码来源:SelectServer.java

示例10: serviceAdded

import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
/*************************************************************************
 * Listener Callbacks - from ServiceListener and ServiceTypeListener
 ************************************************************************/
@Override
public void serviceAdded(ServiceEvent event) {
    final ServiceInfo service_info = event.getInfo();
    // might need to add a timeout as a last arg here
    // true tells it to keep resolving when new, new info comes in (persistent).
    jmmdns.getServiceInfos(service_info.getType(), service_info.getName(), true);
    ZeroconfDiscoveryHandler callback = listener_callbacks.get(service_info.getType());
    if ( callback != null ) {
        callback.serviceAdded(toDiscoveredService(service_info));
    } else {
        logger.println("[+] Service         : " + service_info.getQualifiedName());
    }
}
 
开发者ID:rosalfred,项目名称:smarthome_network_zeroconf,代码行数:17,代码来源:Zeroconf.java

示例11: 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);
    }
}
 
开发者ID:rosalfred,项目名称:smarthome_network_zeroconf,代码行数:12,代码来源:Zeroconf.java

示例12: handleServiceResolved

import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
void handleServiceResolved(ServiceEvent event)
{
    List<ServiceListenerStatus> list = _serviceListeners.get(event.getType().toLowerCase());
    final List<ServiceListenerStatus> listCopy;
    if ((list != null) && (!list.isEmpty()))
    {
        if ((event.getInfo() != null) && event.getInfo().hasData())
        {
            final ServiceEvent localEvent = event;
            synchronized (list)
            {
                listCopy = new ArrayList<ServiceListenerStatus>(list);
            }
            for (final ServiceListenerStatus listener : listCopy)
            {
                _executor.submit(new Runnable() {
                    /** {@inheritDoc} */
                    @Override
                    public void run()
                    {
                        listener.serviceResolved(localEvent);
                    }
                });
            }
        }
    }
}
 
开发者ID:blackshadowwalker,项目名称:log4j-collector,代码行数:28,代码来源:JmDNSImpl.java

示例13: 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

示例14: serviceResolved

import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
public void serviceResolved(ServiceEvent event) {
    mResolvedServiceInfo = event.getInfo();
    mIsResolved = true;
    new Handler(Looper.getMainLooper()).post(new Runnable() {
        @Override
        public void run() {
            mListener.onServiceResolved(mResolvedServiceInfo);
        }
    });
    shutdown();
    mSleepingThread.interrupt();
}
 
开发者ID:openhab,项目名称:openhab-android,代码行数:13,代码来源:AsyncServiceResolver.java

示例15: serviceAdded

import javax.jmdns.ServiceEvent; //导入方法依赖的package包/类
@Override
public void serviceAdded(ServiceEvent se) {
    if (se.getInfo() != null) {
        ChromeCast device = new ChromeCast(mDNS, se.getInfo().getName());
        chromeCasts.add(device);
        for (ChromeCastsListener nextListener : listeners) {
            nextListener.newChromeCastDiscovered(device);
        }
    }
}
 
开发者ID:vitalidze,项目名称:chromecast-java-api-v2,代码行数:11,代码来源:ChromeCasts.java


注:本文中的javax.jmdns.ServiceEvent.getInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。