Search in sources :

Example 56 with EntityBareJid

use of org.jxmpp.jid.EntityBareJid in project Smack by igniterealtime.

the class MultiUserChatManager method getRoomsHostedBy.

/**
 * Returns a Map 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 map from the room's address to its HostedRoom information.
 * @throws XMPPErrorException if there was an XMPP error returned.
 * @throws NoResponseException if there was no response from the remote entity.
 * @throws NotConnectedException if the XMPP connection is not connected.
 * @throws InterruptedException if the calling thread was interrupted.
 * @throws NotAMucServiceException if the entity is not a MUC serivce.
 * @since 4.3.1
 */
public Map<EntityBareJid, HostedRoom> getRoomsHostedBy(DomainBareJid serviceName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAMucServiceException {
    if (!providesMucService(serviceName)) {
        throw new NotAMucServiceException(serviceName);
    }
    DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(serviceName);
    List<DiscoverItems.Item> items = discoverItems.getItems();
    Map<EntityBareJid, HostedRoom> answer = new HashMap<>(items.size());
    for (DiscoverItems.Item item : items) {
        HostedRoom hostedRoom = new HostedRoom(item);
        HostedRoom previousRoom = answer.put(hostedRoom.getJid(), hostedRoom);
        assert previousRoom == null;
    }
    return answer;
}
Also used : HashMap(java.util.HashMap) WeakHashMap(java.util.WeakHashMap) DiscoverItems(org.jivesoftware.smackx.disco.packet.DiscoverItems) NotAMucServiceException(org.jivesoftware.smackx.muc.MultiUserChatException.NotAMucServiceException) EntityBareJid(org.jxmpp.jid.EntityBareJid)

Aggregations

EntityBareJid (org.jxmpp.jid.EntityBareJid)56 SmackIntegrationTest (org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest)30 XMPPException (org.jivesoftware.smack.XMPPException)21 Resourcepart (org.jxmpp.jid.parts.Resourcepart)21 SmackException (org.jivesoftware.smack.SmackException)20 TestNotPossibleException (org.igniterealtime.smack.inttest.TestNotPossibleException)16 ResultSyncPoint (org.igniterealtime.smack.inttest.util.ResultSyncPoint)16 EntityFullJid (org.jxmpp.jid.EntityFullJid)15 SimpleResultSyncPoint (org.igniterealtime.smack.inttest.util.SimpleResultSyncPoint)6 Presence (org.jivesoftware.smack.packet.Presence)6 Jid (org.jxmpp.jid.Jid)6 Message (org.jivesoftware.smack.packet.Message)5 ArrayList (java.util.ArrayList)4 DiscoverItems (org.jivesoftware.smackx.disco.packet.DiscoverItems)4 MUCUser (org.jivesoftware.smackx.muc.packet.MUCUser)4 XmppStringprepException (org.jxmpp.stringprep.XmppStringprepException)4 UserJid (com.xabber.android.data.entity.UserJid)3 HashMap (java.util.HashMap)3 IOException (java.io.IOException)2 AbstractSmackIntegrationTest (org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest)2