Search in sources :

Example 11 with ServiceDiscoveryManager

use of org.jivesoftware.smackx.ServiceDiscoveryManager in project ecf by eclipse.

the class XMPPChatRoomManager method checkRoom.

/**
 * check if the MultiUserChat room is already existing on the XMPP server.
 *
 * @param conference
 * @param room
 *            the name of the room
 * @return true, if the room exists, false otherwise
 * @throws XMPPException
 */
protected boolean checkRoom(String conference, String room) throws XMPPException {
    final XMPPConnection conn = ecfConnection.getXMPPConnection();
    final ServiceDiscoveryManager serviceDiscoveryManager = new ServiceDiscoveryManager(conn);
    final DiscoverItems result = serviceDiscoveryManager.discoverItems(conference);
    for (final Iterator items = result.getItems(); items.hasNext(); ) {
        final DiscoverItems.Item item = ((DiscoverItems.Item) items.next());
        if (room.equals(item.getEntityID())) {
            return true;
        }
    }
    return false;
}
Also used : Iterator(java.util.Iterator) DiscoverItems(org.jivesoftware.smackx.packet.DiscoverItems) XMPPConnection(org.jivesoftware.smack.XMPPConnection) ServiceDiscoveryManager(org.jivesoftware.smackx.ServiceDiscoveryManager)

Aggregations

ServiceDiscoveryManager (org.jivesoftware.smackx.ServiceDiscoveryManager)11 ArrayList (java.util.ArrayList)6 DiscoverItems (org.jivesoftware.smackx.packet.DiscoverItems)6 DiscoverInfo (org.jivesoftware.smackx.packet.DiscoverInfo)5 XMPPException (org.jivesoftware.smack.XMPPException)3 Iterator (java.util.Iterator)1 XMPPConnection (org.jivesoftware.smack.XMPPConnection)1 Identity (org.jivesoftware.smackx.packet.DiscoverInfo.Identity)1 Item (org.jivesoftware.smackx.packet.DiscoverItems.Item)1