简体   繁体   中英

Getting list of contacts with gloox

I have followed the included example within the gloox source code but cannot get it to work, nor can I find ANYWHERE through Google that's an example of what I am after. I desire a way to obtain the list of added XMPP contacts (roster, I believe?) upon making a connection to an XMPP server. The code I have currently been trying is below:

void GekkoFyre::TuiHangouts::handleRoster(const Roster &roster)
{
    Roster::const_iterator it = roster.begin();
    for ( ; it != roster.end(); ++it) {
        rosterOutBuf.push_back((*it).second->name().c_str());
    }

    gui_userRosterList(userListWin, rosterOutBuf, 0);
}

Stepping through the code, I can see that this virtual function does not even activate. What am I doing wrong and can anyone offer a solution? Or even better, an example to follow from? Thank you in advance.

PS I don't even know if this code is written correctly, since I cannot debug it if it doesn't activate!

Nevermind, silly me! I fixed the issue with the following code elsewhere:

#include <gloox/rostermanager.h>

Client *client = new Client(jid, passwd);
client->rosterManager()->registerRosterListener(this);

Apologies if I annoyed anyone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM