Пример #1
0
/** Triggers an asynchronous request to download the friends for this user.
 *  The state of this profile is changed to be fetching,
 *  and will be reset to ready when the server request returns.
 */
void OnlineProfile::fetchFriends()
{
    assert(PlayerManager::isCurrentLoggedIn());
    if (m_has_fetched_friends)
        return;

    m_state = State(m_state | S_FETCHING_FRIENDS);

    // ------------------------------------------------------------------------
    class FriendsListRequest : public XMLRequest
    {
    public:
        FriendsListRequest() : XMLRequest(true, true) {}
        virtual void callback()
        {
            uint32_t user_id = 0;
            getXMLData()->get("visitingid", &user_id);
            OnlineProfile *profile = ProfileManager::get()->getProfileByID(user_id);
            if (profile)
                profile->storeFriends(getXMLData());
        }   // callback
    };   // class FriendsListRequest
    // ------------------------------------------------------------------------

    FriendsListRequest * request = new FriendsListRequest();
    PlayerManager::setUserDetails(request, "get-friends-list");
    request->addParameter("visitingid", m_id);
    RequestManager::get()->addRequest(request);
}   // fetchFriends
Пример #2
0
 void Profile::requestFriendsList()
 {
     assert(CurrentUser::get()->isRegisteredUser());
     FriendsListRequest * request = new FriendsListRequest();
     request->setServerURL("client-user.php");
     request->addParameter("action","get-friends-list");
     request->addParameter("token", CurrentUser::get()->getToken());
     request->addParameter("userid", CurrentUser::get()->getID());
     request->addParameter("visitingid", m_id);
     RequestManager::get()->addRequest(request);
 }