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


Java ServiceDiscoveryManager.discoverItems方法代码示例

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


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

示例1: discoverItemsByFeature

import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private List<String> discoverItemsByFeature(XmppURI uri, List<String> features) throws XMPPException, IOException, SmackException {
    // discover items
    ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connectionManager.getConnection());
    DiscoverItems discoverItems = discoveryManager.discoverItems(uri.getDomain());
    List<DiscoverItems.Item> items = discoverItems.getItems();
    List<String> result = new ArrayList<>();
    // discover infos per item and check if specified feature set is supported
    for (DiscoverItems.Item item : items) {
        DiscoverInfo discoverInfo = discoveryManager.discoverInfo(item.getEntityID());
        boolean conatinsAllFeatures = true;
        for (String feature : features) {
            if (!discoverInfo.containsFeature(feature)) {
                conatinsAllFeatures = false;
                break;
            }
        }
        if (conatinsAllFeatures) {
            result.add(item.getEntityID());
        } else if (logger.isDebugEnabled()) {
            logger.debug("Entity {} does not support the specified features.", item.getEntityID());
        }
    }
    return result;
}
 
开发者ID:citlab,项目名称:Intercloud,代码行数:25,代码来源:XmppService.java

示例2: perform

import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
    String entID = sampler.getPropertyAsString(ENTITY_ID);
    res.setSamplerData("Entity ID: " + entID);
    ServiceDiscoveryManager discoMgr = ServiceDiscoveryManager.getInstanceFor(sampler.getXMPPConnection());
    IQ info;
    if (Type.valueOf(sampler.getPropertyAsString(TYPE)) == Type.info) {
        info = discoMgr.discoverInfo(entID);
    } else {
        info = discoMgr.discoverItems(entID);
    }
    res.setResponseData(info.toXML().toString().getBytes());
    return res;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:15,代码来源:ServiceDiscovery.java

示例3: getHostedRooms

import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
 * Returns a List of HostedRooms where each HostedRoom has the XMPP address of the room and the room's name.
 * Once discovered the rooms hosted by a chat service it is possible to discover more detailed room information or
 * join the room.
 *
 * @param serviceName the service that is hosting the rooms to discover.
 * @return a collection of HostedRooms.
 * @throws XMPPErrorException
 * @throws NoResponseException
 * @throws NotConnectedException
 */
public List<HostedRoom> getHostedRooms(String serviceName) throws NoResponseException, XMPPErrorException,
                NotConnectedException {
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection());
    DiscoverItems discoverItems = discoManager.discoverItems(serviceName);
    List<DiscoverItems.Item> items = discoverItems.getItems();
    List<HostedRoom> answer = new ArrayList<HostedRoom>(items.size());
    for (DiscoverItems.Item item : items) {
        answer.add(new HostedRoom(item));
    }
    return answer;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:23,代码来源:MultiUserChatManager.java

示例4: determineProxies

import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
 * Returns a list of JIDs of SOCKS5 proxies by querying the XMPP server. The SOCKS5 proxies are
 * in the same order as returned by the XMPP server.
 * 
 * @return list of JIDs of SOCKS5 proxies
 * @throws XMPPErrorException if there was an error querying the XMPP server for SOCKS5 proxies
 * @throws NoResponseException if there was no response from the server.
 * @throws NotConnectedException 
 */
private List<String> determineProxies() throws NoResponseException, XMPPErrorException, NotConnectedException {
    XMPPConnection connection = connection();
    ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);

    List<String> proxies = new ArrayList<String>();

    // get all items from XMPP server
    DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(connection.getServiceName());

    // query all items if they are SOCKS5 proxies
    for (Item item : discoverItems.getItems()) {
        // skip blacklisted servers
        if (this.proxyBlacklist.contains(item.getEntityID())) {
            continue;
        }

        DiscoverInfo proxyInfo;
        try {
            proxyInfo = serviceDiscoveryManager.discoverInfo(item.getEntityID());
        }
        catch (NoResponseException|XMPPErrorException e) {
            // blacklist errornous server
            proxyBlacklist.add(item.getEntityID());
            continue;
        }

        if (proxyInfo.hasIdentity("proxy", "bytestreams")) {
            proxies.add(item.getEntityID());
        } else {
            /*
             * server is not a SOCKS5 proxy, blacklist server to skip next time a Socks5
             * bytestream should be established
             */
            this.proxyBlacklist.add(item.getEntityID());
        }
    }

    return proxies;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:49,代码来源:Socks5BytestreamManager.java

示例5: serviceAvailable

import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
 * Check if the server support STUN Service.
 *
 * @param connection the connection
 * @return true if the server support STUN
 * @throws SmackException 
 * @throws XMPPException 
 */
public static boolean serviceAvailable(XMPPConnection connection) throws XMPPException, SmackException {

    if (!connection.isConnected()) {
        return false;
    }

    LOGGER.fine("Service listing");

    ServiceDiscoveryManager disco = ServiceDiscoveryManager.getInstanceFor(connection);
    DiscoverItems items = disco.discoverItems(connection.getServiceName());

    for (DiscoverItems.Item item : items.getItems()) {
        DiscoverInfo info = disco.discoverInfo(item.getEntityID());

        for (DiscoverInfo.Identity identity : info.getIdentities()) {
            if (identity.getCategory().equals("proxy") && identity.getType().equals("stun"))
                if (info.containsFeature(NAMESPACE))
                    return true;
        }

        LOGGER.fine(item.getName() + "-" + info.getType());

    }

    return false;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:35,代码来源:STUN.java

示例6: discover

import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private void discover() throws XMPPErrorException, URISyntaxException, SmackException, XmlException {
	System.out.println("discover root services");
	// Obtain the ServiceDiscoveryManager associated with my XMPPConnection
	ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
	// Get the items of a given XMPP entity
	// This gets the items associated with online catalog service
	DiscoverItems discoItems = discoManager.discoverItems(TEST_DOMAIN);
	// Get the discovered items of the queried XMPP entity
	List<Item> items = discoItems.getItems();
	// set exchange and root server
	for(Item item : items) {
		System.out.println(item.getEntityID());
		if(ServiceNames.RootComponentName.equals(item.getName()))
			rootURI = item.getEntityID();
		else if(ServiceNames.ExchangeComponentName.equals(item.getName()))
			exchangeURI = item.getEntityID();
	}

	// discover root features
	if(rootURI != null) {
		checkFeatures(discoManager, rootURI);
	}

	// discover exchange features
	if(exchangeURI != null) {
		checkFeatures(discoManager, exchangeURI);
	}
}
 
开发者ID:citlab,项目名称:Intercloud,代码行数:29,代码来源:TestClient.java

示例7: discover

import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private EnumMap<Feature, JID> discover(JID entity, boolean withItems) {
    // NOTE: smack automatically creates instances of SDM and CapsM and connects them
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(mConn);

    // 1. get features from server
    EnumMap<Feature, JID> features = discover(discoManager, entity);
    if (features == null)
        return new EnumMap<>(FeatureDiscovery.Feature.class);

    if (!withItems)
        return features;

    // 2. get server items
    DiscoverItems items;
    try {
        items = discoManager.discoverItems(entity.toBareSmack());
    } catch (SmackException.NoResponseException |
            XMPPException.XMPPErrorException |
            SmackException.NotConnectedException |
            InterruptedException ex) {
        LOGGER.log(Level.WARNING, "can't get service discovery items", ex);
        return features;
    }

    // 3. get features from server items
    for (DiscoverItems.Item item: items.getItems()) {
        EnumMap<Feature, JID> itemFeatures = discover(discoManager, JID.fromSmack(item.getEntityID()));
        if (itemFeatures != null)
            features.putAll(itemFeatures);
    }

    LOGGER.info("supported server features: "+features);
    return features;
}
 
开发者ID:kontalk,项目名称:desktopclient-java,代码行数:35,代码来源:FeatureDiscovery.java


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