powered by Jive Software

How to get available groups and user on a server

Hi,

I am starting to develop a Client using Smack

As I am starting the project I thought that the first thing to do when logging on to a server will be

to look what public groups and users are available on it. This will allow the user to interact with these groups and users.

How do I get it using the API?

For example when I connect to jabber.org. I wish to find out the available groups/users so I can add them to my user’'s roster.

Hopefully I make some sense.

Thanks a lot!

Ted

The idea is somewhat listed in this method:

private void showRoster(Roster roster){
    try{
        Iterator groupItems = roster.getGroups();
     Iterator unfiledItems = roster.getUnfiledEntries();
        RosterGroup group;
        Vector list = new Vector();
        RosterEntry entry;
        while (unfiledItems.hasNext()) {
         entry = (RosterEntry)unfiledItems.next();
            list.add(entry.getUser());
        }         while (groupItems.hasNext()) {
            group = (RosterGroup)groupItems.next();
            list.add(group.getName());
        }         dataList.setListData(list);
          
    }
    catch(Exception e){
        e.printStackTrace(System.out);
        System.out.println("e "+e);
    }
}

Hi,

I am still in the dark but it looks like we can extend IQ, somewhat similar to theRosterPacket for browse

Browse can provide the resource discovery service. It might have to use some recursivenace in the process to get the elements of each category the server returns i.e. people, conferences, boots etc.

http://www.jabber.org/jeps/jep-0011.html

On a separate note how do I get the Smack debug functionality, it seems to be missing from the package.

Thanks!

Ted

Yes, you have the browse option and the agents option too.

Browser it’‘s a new “feature” of jabber, and it’‘s not oficial yet, but must of the servers have implemented that option. For agents option, it can be said the agents would be deprecated for browse option, soo you don’'t need to implement it!

About the debug mode, in XMPPConnection class you have a declaration like this one:

public static boolean DEBUG_ENABLED = Boolean.getBoolean(“smack.debugEnabled”);

To active the debug mode I change it to:

public static boolean DEBUG_ENABLED = true;

Nuno Agapito

For more information and more correct you can always see the documentation of smack. It has information about the debug mode:

http://www.jivesoftware.com/xmpp/smack/documentation/debugging.html