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


Java JmDNS.getServiceInfo方法代码示例

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


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

示例1: testWaitAndQueryForServiceOnOtherRegistry

import javax.jmdns.JmDNS; //导入方法依赖的package包/类
@Test
public void testWaitAndQueryForServiceOnOtherRegistry() throws IOException {
    System.out.println("Unit Test: testWaitAndQueryForServiceOnOtherRegistry()");
    JmDNS registry = null;
    JmDNS newServiceRegistry = null;
    try {
        newServiceRegistry = JmDNS.create();
        registry = JmDNS.create();

        registry.registerService(service);

        ServiceInfo fetchedService = newServiceRegistry.getServiceInfo(service.getType(), service.getName());

        assertEquals("Did not get the expected service info: ", service, fetchedService);
    } finally {
        if (registry != null) registry.close();
        if (newServiceRegistry != null) newServiceRegistry.close();
    }
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:20,代码来源:JmDNSTest.java

示例2: unregister

import javax.jmdns.JmDNS; //导入方法依赖的package包/类
public void unregister(String type, String domain, String name) {

            for (JmDNS publisher : publishers) {
                ServiceInfo serviceInfo = publisher.getServiceInfo(type + domain, name, 5000);
                if (serviceInfo != null) {
                    publisher.unregisterService(serviceInfo);
                }
            }

        }
 
开发者ID:becvert,项目名称:cordova-plugin-zeroconf,代码行数:11,代码来源:ZeroConf.java

示例3: ChromeCast

import javax.jmdns.JmDNS; //导入方法依赖的package包/类
ChromeCast(JmDNS mDNS, String name) {
    this.name = name;
    ServiceInfo serviceInfo = mDNS.getServiceInfo(SERVICE_TYPE, name);
    this.address = serviceInfo.getInet4Addresses()[0].getHostAddress();
    this.port = serviceInfo.getPort();
    this.appsURL = serviceInfo.getURLs().length == 0 ? null : serviceInfo.getURLs()[0];
    this.application = serviceInfo.getApplication();

    this.title = serviceInfo.getPropertyString("fn");
    this.appTitle = serviceInfo.getPropertyString("rs");
    this.model = serviceInfo.getPropertyString("md");
}
 
开发者ID:vitalidze,项目名称:chromecast-java-api-v2,代码行数:13,代码来源:ChromeCast.java

示例4: testQueryMyService

import javax.jmdns.JmDNS; //导入方法依赖的package包/类
@Test
public void testQueryMyService() throws IOException {
    System.out.println("Unit Test: testQueryMyService()");
    JmDNS registry = null;
    try {
        registry = JmDNS.create();
        registry.registerService(service);
        ServiceInfo queriedService = registry.getServiceInfo(service.getType(), service.getName());
        assertEquals(service, queriedService);
    } finally {
        if (registry != null) registry.close();
    }
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:14,代码来源:JmDNSTest.java

示例5: testRegisterAndListServiceOnOtherRegistry

import javax.jmdns.JmDNS; //导入方法依赖的package包/类
@Test
public void testRegisterAndListServiceOnOtherRegistry() throws IOException, InterruptedException {
    System.out.println("Unit Test: testRegisterAndListServiceOnOtherRegistry()");
    JmDNS registry = null;
    JmDNS newServiceRegistry = null;
    try {
        registry = JmDNS.create("Registry");
        registry.registerService(service);

        newServiceRegistry = JmDNS.create("Listener");
        Thread.sleep(6000);
        ServiceInfo[] fetchedServices = newServiceRegistry.list(service.getType());
        assertEquals("Did not get the expected services listed:", 1, fetchedServices.length);
        assertEquals("Did not get the expected service type:", service.getType(), fetchedServices[0].getType());
        assertEquals("Did not get the expected service name:", service.getName(), fetchedServices[0].getName());
        assertEquals("Did not get the expected service fully qualified name:", service.getQualifiedName(), fetchedServices[0].getQualifiedName());
        newServiceRegistry.getServiceInfo(service.getType(), service.getName());

        assertEquals("Did not get the expected service info: ", service, fetchedServices[0]);
        registry.close();
        registry = null;
        // According to the spec the record disappears from the cache 1s after it has been unregistered
        // without sleeping for a while, the service would not be unregistered fully
        Thread.sleep(1500);
        fetchedServices = newServiceRegistry.list(service.getType());
        assertEquals("The service was not cancelled after the close:", 0, fetchedServices.length);
    } finally {
        if (registry != null) registry.close();
        if (newServiceRegistry != null) newServiceRegistry.close();
    }
}
 
开发者ID:josephw,项目名称:jmdns,代码行数:32,代码来源:JmDNSTest.java


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