std::future<bool> UserData::SendFriendResponse(const UUID &id, const UUID &requester, const std::string &response, BooleanCallback success, APIFailureCallback failure) { return std::async(std::launch::async, [=]() -> bool { std::stringstream url; url << "/friends/" << id.toString() << "/response"; std::map<std::string, std::string> params{ std::make_pair("requester_id", requester.toString()), std::make_pair("action", response) }; std::string error; APIRequestManager *manager = APIRequestManager::GetDefaultManager(); boost::optional<std::string> response = manager->Send(url.str(), "POST", params, error); if (response.is_initialized()) { Poco::JSON::Parser parser; auto jsonObject = parser.parse(response.get()).extract<JSONObject::Ptr>(); return jsonObject->getValue<bool>("success"); } else { if (failure) { failure(error); } return false; } }); }
const std::string& get_current_thread_name() { #if HAVE_THREAD_LOCAL_SPECIFIER if (!current_name.empty()) { return current_name; } #else if (current_name.get()) { return *current_name; } #endif std::ostringstream out; out << std::this_thread::get_id(); set_current_thread_name(out.str()); return get_current_thread_name(); }