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


Java ServiceDiscoveryManager.discoverItems方法代码示例

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


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

示例1: getServiceNames

import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
 * Returns a collection with the XMPP addresses of the Multi-User Chat services.
 *
 * @param connection the XMPP connection to use for discovering Multi-User Chat services.
 * @return a collection with the XMPP addresses of the Multi-User Chat services.
 * @throws XMPPException if an error occured while trying to discover MUC services.
 */
public static Collection<String> getServiceNames(Connection connection) throws XMPPException {
    final List<String> answer = new ArrayList<String>();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
    DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
    for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
        DiscoverItems.Item item = it.next();
        try {
            DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
            if (info.containsFeature("http://jabber.org/protocol/muc")) {
                answer.add(item.getEntityID());
            }
        }
        catch (XMPPException e) {
            // Trouble finding info in some cases. This is a workaround for
            // discovering info on remote servers.
        }
    }
    return answer;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:27,代码来源:MultiUserChat.java

示例2: getServiceNames

import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
 * Returns a collection with the XMPP addresses of the Multi-User Chat
 * services.
 * 
 * @param connection
 *            the XMPP connection to use for discovering Multi-User Chat
 *            services.
 * @return a collection with the XMPP addresses of the Multi-User Chat
 *         services.
 * @throws XMPPException
 *             if an error occured while trying to discover MUC services.
 */
public static Collection<String> getServiceNames(Connection connection)
		throws XMPPException {
	final List<String> answer = new ArrayList<String>();
	ServiceDiscoveryManager discoManager = ServiceDiscoveryManager
			.getInstanceFor(connection);
	DiscoverItems items = discoManager.discoverItems(connection
			.getServiceName());
	for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
		DiscoverItems.Item item = it.next();
		try {
			DiscoverInfo info = discoManager.discoverInfo(item
					.getEntityID());
			if (info.containsFeature("http://jabber.org/protocol/muc")) {
				answer.add(item.getEntityID());
			}
		} catch (XMPPException e) {
			// Trouble finding info in some cases. This is a workaround for
			// discovering info on remote servers.
		}
	}
	return answer;
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:35,代码来源:MultiUserChat.java

示例3: initProxies

import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
private void initProxies() {
    proxies = new ArrayList<String>();
    ServiceDiscoveryManager manager = ServiceDiscoveryManager
            .getInstanceFor(connection);
    try {
        DiscoverItems discoItems = manager.discoverItems(connection.getServiceName());
        Iterator<DiscoverItems.Item> it = discoItems.getItems();
        while (it.hasNext()) {
            DiscoverItems.Item item = it.next();
            String proxy = checkIsProxy(manager, item);
            if (proxy != null) {
                proxies.add(proxy);
            }
        }
    }
    catch (XMPPException e) {
        return;
    }
    if (proxies.size() > 0) {
        initStreamHosts();
    }
}
 
开发者ID:phoenixNirvana,项目名称:NewCommunication-Android,代码行数:23,代码来源:Socks5TransferNegotiatorManager.java

示例4: getConferenceServices

import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
public Collection<String> getConferenceServices(String server) throws Exception {
    List<String> answer = new ArrayList<String>();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
    DiscoverItems items = discoManager.discoverItems(server);
    for (Iterator<Item> it = items.getItems(); it.hasNext();) {
        Item item = it.next();
        if (item.getEntityID().startsWith("conference") || item.getEntityID().startsWith("private")) {
            answer.add(item.getEntityID());
        }
        else {
            try {
                DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
                if (info.containsFeature("http://jabber.org/protocol/muc")) {
                    answer.add(item.getEntityID());
                }
            }
            catch (XMPPException e) {
                // Nothing to do
            }
        }
    }
    return answer;
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:24,代码来源:ConferenceServiceBrowser.java

示例5: getConferenceServices

import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
private Collection<String> getConferenceServices(String server) throws Exception {
    List<String> answer = new ArrayList<String>();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
    DiscoverItems items = discoManager.discoverItems(server);
    for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
        DiscoverItems.Item item = (DiscoverItems.Item)it.next();
        if (item.getEntityID().startsWith("conference") || item.getEntityID().startsWith("private")) {
            answer.add(item.getEntityID());
        }
        else {
            try {
                DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
                if (info.containsFeature("http://jabber.org/protocol/muc")) {
                    answer.add(item.getEntityID());
                }
            }
            catch (XMPPException e) {
                Log.error("Problem when loading conference service.", e);
            }
        }
    }
    return answer;
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:24,代码来源:BookmarksUI.java

示例6: displayRoomInformation

import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
public void displayRoomInformation(final String roomJID) {
    SwingWorker worker = new SwingWorker() {
        RoomInfo roomInfo = null;
        DiscoverItems items = null;

        public Object construct() {
            try {
                roomInfo = MultiUserChat.getRoomInfo(SparkManager.getConnection(), roomJID);


                ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
                items = manager.discoverItems(roomJID);
            }
            catch (XMPPException e) {
                Log.error(e);
            }
            return "ok";
        }

        public void finished() {
            setupRoomInformationUI(roomJID, roomInfo, items);
        }
    };

    worker.start();
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:27,代码来源:RoomBrowser.java

示例7: isSoftPhonePluginInstalled

import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
 * Does a service discovery on the server to see if a SIPpark Manager is
 * enabled.
 *
 * @param con the XMPPConnection to use.
 * @return true if SIPpark Manager is available.
 */
public static boolean isSoftPhonePluginInstalled(XMPPConnection con) {
    if (!con.isConnected()) {
        return false;
    }

    ServiceDiscoveryManager disco = ServiceDiscoveryManager
            .getInstanceFor(con);
    try {
        DiscoverItems items = disco.discoverItems(con.getServiceName());
        Iterator<DiscoverItems.Item> iter = items.getItems();
        while (iter.hasNext()) {
            DiscoverItems.Item item = iter.next();
            if ("SIP Controller".equals(item.getName())) {
                Log.debug("SIP Controller Found");
                return true;
            }
        }
    }
    catch (XMPPException e) {
        Log.error("isSparkPluginInstalled", e);
    }

    return false;

}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:33,代码来源:SipAccountPacket.java

示例8: getHostedRooms

import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
 * Returns a collection 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 connection the XMPP connection to use for discovering hosted rooms by the MUC service.
 * @param serviceName the service that is hosting the rooms to discover.
 * @return a collection of HostedRooms.
 * @throws XMPPException if an error occured while trying to discover the information.
 */
public static Collection<HostedRoom> getHostedRooms(Connection connection, String serviceName)
        throws XMPPException {
    List<HostedRoom> answer = new ArrayList<HostedRoom>();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
    DiscoverItems items = discoManager.discoverItems(serviceName);
    for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
        answer.add(new HostedRoom(it.next()));
    }
    return answer;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:21,代码来源:MultiUserChat.java

示例9: getWorkgroupNames

import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
public static Collection getWorkgroupNames() {
    final List workgroupNames = new ArrayList();

    ChatManager chatManager = ChatManager.getInstance();
    ConnectionSettings connectionSettings = chatManager.getChatSettingsManager().getSettings();
    if (connectionSettings == null) {
        return workgroupNames;
    }
    String host = connectionSettings.getServerDomain();
    XMPPConnection con = chatManager.getGlobalConnection();
    if (con == null) {
        return workgroupNames;
    }
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
    DiscoverItems result = null;
    try {
        result = discoManager.discoverItems("workgroup." + host);
    }
    catch (XMPPException e) {
        return workgroupNames;
    }
    Iterator iter = result.getItems();
    while (iter.hasNext()) {
        DiscoverItems.Item item = (DiscoverItems.Item)iter.next();
        String workgroupName = item.getName();
        workgroupNames.add(workgroupName);
    }
    return workgroupNames;
}
 
开发者ID:igniterealtime,项目名称:Fastpath-webchat,代码行数:30,代码来源:WorkgroupStatus.java

示例10: serviceAvailable

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

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

    LOGGER.debug("Service listing");

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

        Iterator<DiscoverItems.Item> iter = items.getItems();
        while (iter.hasNext()) {
            DiscoverItems.Item item = iter.next();
            DiscoverInfo info = disco.discoverInfo(item.getEntityID());

            Iterator<DiscoverInfo.Identity> iter2 = info.getIdentities();
            while (iter2.hasNext()) {
                DiscoverInfo.Identity identity = iter2.next();
                if (identity.getCategory().equals("proxy") && identity.getType().equals("stun"))
                    if (info.containsFeature(NAMESPACE))
                        return true;
            }

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

        }
    }
    catch (XMPPException e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:bejayoharen,项目名称:java-bells,代码行数:42,代码来源:STUN.java

示例11: determineProxies

import org.jivesoftware.smackx.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 XMPPException if there was an error querying the XMPP server for SOCKS5 proxies
 */
private List<String> determineProxies() throws XMPPException {
    ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection);

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

    // get all items form XMPP server
    DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(this.connection.getServiceName());
    Iterator<Item> itemIterator = discoverItems.getItems();

    // query all items if they are SOCKS5 proxies
    while (itemIterator.hasNext()) {
        Item item = itemIterator.next();

        // skip blacklisted servers
        if (this.proxyBlacklist.contains(item.getEntityID())) {
            continue;
        }

        try {
            DiscoverInfo proxyInfo;
            proxyInfo = serviceDiscoveryManager.discoverInfo(item.getEntityID());
            Iterator<Identity> identities = proxyInfo.getIdentities();

            // item must have category "proxy" and type "bytestream"
            while (identities.hasNext()) {
                Identity identity = identities.next();

                if ("proxy".equalsIgnoreCase(identity.getCategory())
                                && "bytestreams".equalsIgnoreCase(identity.getType())) {
                    proxies.add(item.getEntityID());
                    break;
                }

                /*
                 * server is not a SOCKS5 proxy, blacklist server to skip next time a Socks5
                 * bytestream should be established
                 */
                this.proxyBlacklist.add(item.getEntityID());

            }
        }
        catch (XMPPException e) {
            // blacklist errornous server
            this.proxyBlacklist.add(item.getEntityID());
        }
    }

    return proxies;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:57,代码来源:Socks5BytestreamManager.java

示例12: determineProxies

import org.jivesoftware.smackx.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 XMPPException
 *             if there was an error querying the XMPP server for SOCKS5
 *             proxies
 */
private List<String> determineProxies() throws XMPPException {
	ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
			.getInstanceFor(this.connection);

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

	// get all items form XMPP server
	DiscoverItems discoverItems = serviceDiscoveryManager
			.discoverItems(this.connection.getServiceName());
	Iterator<Item> itemIterator = discoverItems.getItems();

	// query all items if they are SOCKS5 proxies
	while (itemIterator.hasNext()) {
		Item item = itemIterator.next();

		// skip blacklisted servers
		if (this.proxyBlacklist.contains(item.getEntityID())) {
			continue;
		}

		try {
			DiscoverInfo proxyInfo;
			proxyInfo = serviceDiscoveryManager.discoverInfo(item
					.getEntityID());
			Iterator<Identity> identities = proxyInfo.getIdentities();

			// item must have category "proxy" and type "bytestream"
			while (identities.hasNext()) {
				Identity identity = identities.next();

				if ("proxy".equalsIgnoreCase(identity.getCategory())
						&& "bytestreams".equalsIgnoreCase(identity
								.getType())) {
					proxies.add(item.getEntityID());
					break;
				}

				/*
				 * server is not a SOCKS5 proxy, blacklist server to skip
				 * next time a Socks5 bytestream should be established
				 */
				this.proxyBlacklist.add(item.getEntityID());

			}
		} catch (XMPPException e) {
			// blacklist errornous server
			this.proxyBlacklist.add(item.getEntityID());
		}
	}

	return proxies;
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:62,代码来源:Socks5BytestreamManager.java

示例13: retrieveAvailableSpaces

import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
 * Requests the spaces which are available for the user.
 * @return List<Space> A List of all available spaces, with each having their name, id and domain set.
 * @throws SpaceManagementException Thrown when there's an error response from the server.
 */
private List<Space> retrieveAvailableSpaces() throws SpaceManagementException{
	if (getMode() == Mode.OFFLINE || connectionHandler.getNetworkInformation().getSpacesServiceJID() == null){
		return null;
	}
	List<Space> spacesList = new ArrayList<Space>();
	ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
	DiscoverItems itemsInfo;
	try {
		itemsInfo = discoveryManager.discoverItems(connectionHandler.getNetworkInformation().getSpacesServiceJID());
	} catch (XMPPException e) {
		throw new SpaceManagementException("Server didn't respond.", Type.OTHER, e);
	}
	Element element = parsePacketToElement(itemsInfo);
	if ("result".equalsIgnoreCase(element.getAttributeValue("type"))){
		List<Element> items = getChildren(element, "item");
		if (items != null){
			for (Element item:items){
				String domain = item.getAttributeValue("jid").replace(SERVICE_PREFIX, "");
				String[] node = item.getAttributeValue("node").split("#");
				Space.Type type;
				if (node.length>=2){
					type = Space.Type.getType(node[0]);
					if (type == Space.Type.OTHER){
						type = Space.Type.PRIVATE;
					}
				} else {
					type = Space.Type.PRIVATE;
				}
				spacesList.add(
					de.imc.mirror.sdk.android.Space.createSpace(
							item.getAttributeValue("name"),
							item.getAttributeValue("node"),
							domain,
							null,
							type,
							null,
							null,
							PersistenceType.OFF,
							null)
				);
			}
		}
	} //TODO error possible??
	/*else if (iq.getType().equals("error")){
		Log.d("SpaceHandler", iq.error.text.text);
		throw new SpaceManagementException("An error response was received.",  SpaceManagementException.Type.OTHER);
	}*/
	return spacesList;
}
 
开发者ID:MirrorIP,项目名称:msf-spaces-sdk-android,代码行数:55,代码来源:SpaceHandler.java

示例14: getHostedRooms

import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
 * Returns a collection 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 connection
 *            the XMPP connection to use for discovering hosted rooms by the
 *            MUC service.
 * @param serviceName
 *            the service that is hosting the rooms to discover.
 * @return a collection of HostedRooms.
 * @throws XMPPException
 *             if an error occured while trying to discover the information.
 */
public static Collection<HostedRoom> getHostedRooms(Connection connection,
		String serviceName) throws XMPPException {
	List<HostedRoom> answer = new ArrayList<HostedRoom>();
	ServiceDiscoveryManager discoManager = ServiceDiscoveryManager
			.getInstanceFor(connection);
	DiscoverItems items = discoManager.discoverItems(serviceName);
	for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
		answer.add(new HostedRoom(it.next()));
	}
	return answer;
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:27,代码来源:MultiUserChat.java

示例15: discoverCommands

import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
 * Discover the commands of an specific JID. The <code>jid</code> is a
 * full JID.
 *
 * @param jid the full JID to retrieve the commands for.
 * @return the discovered items.
 * @throws XMPPException if the operation failed for some reason.
 */
public DiscoverItems discoverCommands(String jid) throws XMPPException {
    ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
            .getInstanceFor(connection);
    return serviceDiscoveryManager.discoverItems(jid, discoNode);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:14,代码来源:AdHocCommandManager.java


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