Which MUC rooms has user joined?

I am building sort of a Jabber/XMPP bridge to a different proprietary chat software. All users of both Jabber clients and proprietary clients are linked together via one or more MUC rooms. There is an XMPP proxy that joins the MUC as one user and represents the entire “community” of proprietary clients.

The caveat is that I only want the proxy to pass on messages to the proprietary community when one of the Jabber clients tries to initiate a private chat with session with that “community” user from inside the MUC. The problem is, that there is no sense of topic or context once a private chat is initiated, so, if the proprietary chat community is joined in to multiple MUCs (RaceCars and SeattleNightLife for instance), the community will suddenly receive a message and not know from which topic (MUC) the message came.

To help with the issue I’'d like to be able to do some simple correllation to see if the joined rooms of the sender and receiver overlap…but I have not been successful in getting the list of joined MUCs from any users. There is, of course, this example straight out of the documentation:

ServiceDiscoveryManager.getInstanceFor(connection).setNodeInformationProvider(

      "http://jabber.org/protocol/muc#rooms",

new NodeInformationProvider() {

public Iterator getNodeItems() {

ArrayList answer = new ArrayList();

Iterator rooms = MultiUserChat.getJoinedRooms(connection);

while (rooms.hasNext()) {

answer.add(new DiscoverItems.Item((String)rooms.next()));

}

return answer.iterator();

}

});

Which I guess is supposed to set up a way for the discovery service to reply with an answer to exactly the sort of question I’'m trying to ask, however this does not seem to compile because of this line:

“Iterator rooms = MultiUserChat.getJoinedRooms(connection);”

According to what I’‘m seeing, the getJoinedRooms(…) method takes two arguments, connection and user. Even knowing this, I’'m still not smart enough to get this to work… ;(

Can anyone help?

2 Likes

Hey Natron,

Sorry for the late reply. Follow url=http://www.jivesoftware.org/builds/smack/docs/latest/documentation/extension s/muc.html#discojointhis link[/url] to learn how to discover joined rooms of another user. The code that you posted is used internally by the MultiUserChat class to answer an IQ disco request for getting the joined rooms.

Regards,

– Gato

1 Like