0

i'm working currently on a openfire server where i have different user and 4 possible subcriptions topics. now i want to show topics which are subscribed on the start of the client.

Is there a way to search for subscriptions a user have via Smac (xmpp) ?

1 Answer 1

0

You should be able to use the PubSubManager (<- Smack api doc link) to get all the subscriptions and nodes. Below uses PubSubManager to get a list of subscriptions and then use that list to get all the subscription ids:

try
{
    PubSubManager manager = new PubSubManager(XMPPClient.connection);
    List<Subscription> listSubs = manager.getSubscriptions();
    for(int i = 0; i < listSubs.size(); i++)
    {
        System.out.println(listSubs.get(i).getId());
    }
}
catch(XMPPException e)
{
    System.out.println(e.getMessage());
}

Simple example to print all ids of subscriptions that connection is subscribed to. XMPPClient is the name of your Smack XMPPClient instance. However, if you need the nodes and specific node information you can get the nodes from the ids using the manager and then get node info using the Node class. Check that documentation, you can get pretty much everything you need about the subscription nodes with that.

Hope that helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.