Search code examples
xmppsmackservice-discovery

How to discover if the currently connected server provides a MUC component


Is it possible, and then how, to discover if the current server provides a MUC component with Smack?

I try to make the configuration for the end user as easy as possible. So that he has to enter just the JID and the password. If the server belonging to the JID has a MUC component, the component should be used for new MUCs. If the server provides no MUC component, a default MUC component is used.


Solution

  • You want to use XEP-0030 (Service Discovery) for this. ServiceDiscoveryManager provides an implementation. Call getInstanceFor(connection), then discoverItems("example.com"), then then discoverInfo(jid) for each item returned from discoverItems. The correct component will implement the http://jabber.org/protocol/muc feature.