當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。