如何发现当前连接的服务器是否提供MUC组件
是否可以以及如何发现当前服务器是否提供带有 Smack 的 MUC 组件?
我尝试让最终用户的配置尽可能简单。这样他只需输入 JID 和密码。如果属于 JID 的服务器具有 MUC 组件,则该组件应用于新的 MUC。如果服务器不提供MUC组件,则使用默认的MUC组件。
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.
为此,您需要使用 XEP-0030(服务发现)。 ServiceDiscoveryManager 提供了一个实现。对于从 discoveryItems 返回的每个项目,分别调用
getInstanceFor(connection)
、discoverItems("example.com")
、discoverInfo(jid)
。正确的组件将实现http://jabber.org/protocol/muc
功能。You want to use XEP-0030 (Service Discovery) for this. ServiceDiscoveryManager provides an implementation. Call
getInstanceFor(connection)
, thendiscoverItems("example.com")
, then thendiscoverInfo(jid)
for each item returned from discoverItems. The correct component will implement thehttp://jabber.org/protocol/muc
feature.