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


Java DiscoverItems类代码示例

本文整理汇总了Java中org.jivesoftware.smackx.packet.DiscoverItems的典型用法代码示例。如果您正苦于以下问题:Java DiscoverItems类的具体用法?Java DiscoverItems怎么用?Java DiscoverItems使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: process

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的package包/类
public void process(Packet packet) {
  if (roomResponseFilter.accept(packet)) {
    final DiscoverItems result = (DiscoverItems) packet;
    final JabberPlayer player = playerMgr.getPlayer(packet.getFrom());
    // Collect the entityID for each returned item
    for (Iterator<DiscoverItems.Item> items = result.getItems(); items.hasNext();) {
      final String roomJID = items.next().getEntityID();
      final JabberRoom room = roomMgr.getRoomByJID(JabberClient.this, roomJID);
      try {
       room.setInfo(MultiUserChat.getRoomInfo(JabberClient.this
            .getConnection(), roomJID));
      }
      catch (XMPPException e) {
        // Ignore Error
      }
      if (!roomJID.equals(monitorRoom.getRoom())) {
        player.join(roomMgr.getRoomByJID(JabberClient.this, roomJID));
      }
    }
    fireRoomsUpdated();
  }
  else if (newPlayerFilter.accept(packet)) {
    sendRoomQuery(getAbsolutePlayerJID(packet.getFrom()));
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:26,代码来源:JabberClient.java

示例2: publishCommands

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的package包/类
/**
 * Publish the commands to an specific JID.
 *
 * @param jid the full JID to publish the commands to.
 * @throws XMPPException if the operation failed for some reason.
 */
public void publishCommands(String jid) throws XMPPException {
    ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
            .getInstanceFor(connection);

    // Collects the commands to publish as items
    DiscoverItems discoverItems = new DiscoverItems();
    Collection<AdHocCommandInfo> xCommandsList = getRegisteredCommands();

    for (AdHocCommandInfo info : xCommandsList) {
        DiscoverItems.Item item = new DiscoverItems.Item(info.getOwnerJID());
        item.setName(info.getName());
        item.setNode(info.getNode());
        discoverItems.addItem(item);
    }

    serviceDiscoveryManager.publishItems(jid, discoNode, discoverItems);
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:24,代码来源:AdHocCommandManager.java

示例3: getJoinedRooms

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的package包/类
/**
 * Returns an Iterator on the rooms where the requested user has joined. The Iterator will
 * contain Strings where each String represents a room (e.g. [email protected]).
 *
 * @param connection the connection to use to perform the service discovery.
 * @param user the user to check. A fully qualified xmpp ID, e.g. [email protected]
 * @return an Iterator on the rooms where the requested user has joined.
 */
public static Iterator<String> getJoinedRooms(Connection connection, String user) {
    try {
        ArrayList<String> answer = new ArrayList<String>();
        // Send the disco packet to the user
        DiscoverItems result =
            ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(user, discoNode);
        // Collect the entityID for each returned item
        for (Iterator<DiscoverItems.Item> items=result.getItems(); items.hasNext();) {
            answer.add(items.next().getEntityID());
        }
        return answer.iterator();
    }
    catch (XMPPException e) {
        e.printStackTrace();
        // Return an iterator on an empty collection
        return new ArrayList<String>().iterator();
    }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:27,代码来源:MultiUserChat.java

示例4: getServiceNames

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的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

示例5: discoverItems

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的package包/类
/**
 * Returns the discovered items of a given XMPP entity addressed by its JID and
 * note attribute. Use this message only when trying to query information which is not 
 * directly addressable.
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the attribute that supplements the 'jid' attribute.
 * @return the discovered items.
 * @throws XMPPException if the operation failed for some reason.
 */
public DiscoverItems discoverItems(String entityID, String node) throws XMPPException {
    // Discover the entity's items
    DiscoverItems disco = new DiscoverItems();
    disco.setType(IQ.Type.GET);
    disco.setTo(entityID);
    disco.setNode(node);

    // Create a packet collector to listen for a response.
    PacketCollector collector =
        connection.createPacketCollector(new PacketIDFilter(disco.getPacketID()));

    connection.sendPacket(disco);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    return (DiscoverItems) result;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:36,代码来源:ServiceDiscoveryManager.java

示例6: publishItems

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的package包/类
/**
 * Publishes new items to a parent entity and node. The item elements to publish MUST have at 
 * least a 'jid' attribute specifying the Entity ID of the item, and an action attribute which 
 * specifies the action being taken for that item. Possible action values are: "update" and 
 * "remove".
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the attribute that supplements the 'jid' attribute.
 * @param discoverItems the DiscoveryItems to publish.
 * @throws XMPPException if the operation failed for some reason.
 */
public void publishItems(String entityID, String node, DiscoverItems discoverItems)
        throws XMPPException {
    discoverItems.setType(IQ.Type.SET);
    discoverItems.setTo(entityID);
    discoverItems.setNode(node);

    // Create a packet collector to listen for a response.
    PacketCollector collector =
        connection.createPacketCollector(new PacketIDFilter(discoverItems.getPacketID()));

    connection.sendPacket(discoverItems);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:35,代码来源:ServiceDiscoveryManager.java

示例7: publishCommands

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的package包/类
/**
 * Publish the commands to an specific JID.
 * 
 * @param jid
 *            the full JID to publish the commands to.
 * @throws XMPPException
 *             if the operation failed for some reason.
 */
public void publishCommands(String jid) throws XMPPException {
	ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
			.getInstanceFor(connection);

	// Collects the commands to publish as items
	DiscoverItems discoverItems = new DiscoverItems();
	Collection<AdHocCommandInfo> xCommandsList = getRegisteredCommands();

	for (AdHocCommandInfo info : xCommandsList) {
		DiscoverItems.Item item = new DiscoverItems.Item(info.getOwnerJID());
		item.setName(info.getName());
		item.setNode(info.getNode());
		discoverItems.addItem(item);
	}

	serviceDiscoveryManager.publishItems(jid, discoNode, discoverItems);
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:26,代码来源:AdHocCommandManager.java

示例8: getJoinedRooms

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的package包/类
/**
 * Returns an Iterator on the rooms where the requested user has joined. The
 * Iterator will contain Strings where each String represents a room (e.g.
 * [email protected]).
 * 
 * @param connection
 *            the connection to use to perform the service discovery.
 * @param user
 *            the user to check. A fully qualified xmpp ID, e.g.
 *            [email protected]
 * @return an Iterator on the rooms where the requested user has joined.
 */
public static Iterator<String> getJoinedRooms(Connection connection,
		String user) {
	try {
		ArrayList<String> answer = new ArrayList<String>();
		// Send the disco packet to the user
		DiscoverItems result = ServiceDiscoveryManager.getInstanceFor(
				connection).discoverItems(user, discoNode);
		// Collect the entityID for each returned item
		for (Iterator<DiscoverItems.Item> items = result.getItems(); items
				.hasNext();) {
			answer.add(items.next().getEntityID());
		}
		return answer.iterator();
	} catch (XMPPException e) {
		e.printStackTrace();
		// Return an iterator on an empty collection
		return new ArrayList<String>().iterator();
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:32,代码来源:MultiUserChat.java

示例9: getServiceNames

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的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

示例10: publishItems

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的package包/类
/**
 * Publishes new items to a parent entity and node. The item elements to
 * publish MUST have at least a 'jid' attribute specifying the Entity ID of
 * the item, and an action attribute which specifies the action being taken
 * for that item. Possible action values are: "update" and "remove".
 * 
 * @param entityID
 *            the address of the XMPP entity.
 * @param node
 *            the attribute that supplements the 'jid' attribute.
 * @param discoverItems
 *            the DiscoveryItems to publish.
 * @throws XMPPException
 *             if the operation failed for some reason.
 */
public void publishItems(String entityID, String node,
		DiscoverItems discoverItems) throws XMPPException {
	discoverItems.setType(IQ.Type.SET);
	discoverItems.setTo(entityID);
	discoverItems.setNode(node);

	// Create a packet collector to listen for a response.
	PacketCollector collector = connection
			.createPacketCollector(new PacketIDFilter(discoverItems
					.getPacketID()));

	connection.sendPacket(discoverItems);

	// Wait up to 5 seconds for a result.
	IQ result = (IQ) collector.nextResult(SmackConfiguration
			.getPacketReplyTimeout());
	// Stop queuing results
	collector.cancel();
	if (result == null) {
		throw new XMPPException("No response from the server.");
	}
	if (result.getType() == IQ.Type.ERROR) {
		throw new XMPPException(result.getError());
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:41,代码来源:ServiceDiscoveryManager.java

示例11: discoverItems

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的package包/类
/**
 * Returns the discovered items of a given XMPP entity addressed by its JID and
 * note attribute. Use this message only when trying to query information which is not 
 * directly addressable.
 * 
 * @param entityID the address of the XMPP entity.
 * @param node the optional attribute that supplements the 'jid' attribute.
 * @return the discovered items.
 * @throws XMPPException if the operation failed for some reason.
 */
public DiscoverItems discoverItems(String entityID, String node) throws XMPPException {
    // Discover the entity's items
    DiscoverItems disco = new DiscoverItems();
    disco.setType(IQ.Type.GET);
    disco.setTo(entityID);
    disco.setNode(node);

    // Create a packet collector to listen for a response.
    PacketCollector collector =
        connection.createPacketCollector(new PacketIDFilter(disco.getPacketID()));

    connection.sendPacket(disco);

    // Wait up to 5 seconds for a result.
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    // Stop queuing results
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from the server.");
    }
    if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
    return (DiscoverItems) result;
}
 
开发者ID:bejayoharen,项目名称:java-bells,代码行数:36,代码来源:ServiceDiscoveryManager.java

示例12: checkIsProxy

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的package包/类
/**
 * Checks the service discovery item returned from a server component to verify if it is
 * a File Transfer proxy or not.
 *
 * @param manager the service discovery manager which will be used to query the component
 * @param item    the discovered item on the server relating
 * @return returns the JID of the proxy if it is a proxy or null if the item is not a proxy.
 */
private String checkIsProxy(ServiceDiscoveryManager manager, DiscoverItems.Item item) {
    DiscoverInfo info;
    try {
        info = manager.discoverInfo(item.getEntityID());
    }
    catch (XMPPException e) {
        return null;
    }
    Iterator<DiscoverInfo.Identity> itx = info.getIdentities();
    while (itx.hasNext()) {
        DiscoverInfo.Identity identity = itx.next();
        if ("proxy".equalsIgnoreCase(identity.getCategory())
                && "bytestreams".equalsIgnoreCase(
                identity.getType())) {
            return info.getFrom();
        }
    }
    return null;
}
 
开发者ID:phoenixNirvana,项目名称:NewCommunication-Android,代码行数:28,代码来源:Socks5TransferNegotiatorManager.java

示例13: initProxies

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的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

示例14: getConferenceServices

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的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

示例15: getConferenceServices

import org.jivesoftware.smackx.packet.DiscoverItems; //导入依赖的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


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