XMPP An Introduction Part VI - Service Discovery

Now that we’ve covered the basic stanza forms, and how we can communicate with XMPP servers and other clients, it’s time to dig deeper. Previously, in the IQ stanza blog, we dove a little bit into service discovery. Here we will look at the service discovery tree in some more detail, exploiting its capabilities and using it to find out who is online, and what services are available.

Service discovery in XMPP comes in two flavors: disco#info and disco#items. Disco#info provides information about the entity in question like software version, or available features. Disco#items provides a list of available items, such as supported features, or members in a chat room. These two XML Namespaces can help you navigate the tree of information from an XMPP server. We’ve already seen what happens when you query the main server with a disco#info stanza, so let’s see what happens when use a disco#items at a MUC component:

Notice however, that usernames are not shown as bare JIDs, but as full JIDs as a part of muc component, which is because when users join a chatroom, they are given an alias from the chatroom. Typically, you will not be able to retrieve a user’s JID from muc component. As we have seen, the disco#info and disco#item XML namespaces can be incredibly handy for navigating the tree of information in an XMPP server. Similar exchanges can be seen for discovering nodes and items in PubSub components, finding available commands and features for components, or potential tasks components can carry out.