mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-29 23:42:06 +01:00
Added support for discovering MUC services. SMACK-39
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2443 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
a6ae5bcc86
commit
1bf4d2fed2
2 changed files with 32 additions and 0 deletions
|
@ -195,6 +195,27 @@ public class MultiUserChat {
|
|||
return new RoomInfo(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 getServiceNames(XMPPConnection connection) throws XMPPException {
|
||||
List answer = new ArrayList();
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
DiscoverItems items = discoManager.discoverItems(connection.getHost());
|
||||
for (Iterator it = items.getItems(); it.hasNext();) {
|
||||
DiscoverItems.Item item = (DiscoverItems.Item) it.next();
|
||||
DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
|
||||
if (info.containsFeature("http://jabber.org/protocol/muc")) {
|
||||
answer.add(item.getEntityID());
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the room this MultiUserChat object represents.
|
||||
*
|
||||
|
|
|
@ -365,6 +365,17 @@ public class MultiUserChatTest extends SmackTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testDiscoverMUCService() {
|
||||
try {
|
||||
Collection services = MultiUserChat.getServiceNames(getConnection(1));
|
||||
assertFalse("No MUC service was found", services.isEmpty());
|
||||
}
|
||||
catch (XMPPException e) {
|
||||
e.printStackTrace();
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testPrivateChat() {
|
||||
try {
|
||||
// User2 joins the new room
|
||||
|
|
Loading…
Reference in a new issue