本文整理汇总了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;
}
示例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() );
}
}
}
示例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);
}
});
}
}
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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 );
}
}
);
}
示例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 );
}
}
);
}
示例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());
}
}
示例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);
}
}
示例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);
}
});
}
}
}
}
示例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);
}
}
示例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();
}
示例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);
}
}
}