std::vector<ServerListSpec> getOnline()
{
	std::ostringstream geturl;
	geturl << g_settings->get("serverlist_url") <<
		"/list?proto_version_min=" << CLIENT_PROTOCOL_VERSION_MIN <<
		"&proto_version_max=" << CLIENT_PROTOCOL_VERSION_MAX;
	Json::Value root = fetchJsonValue(geturl.str(), NULL);

	std::vector<ServerListSpec> server_list;

	if (!root.isObject()) {
		return server_list;
	}

	root = root["list"];
	if (!root.isArray()) {
		return server_list;
	}

	for (unsigned int i = 0; i < root.size(); i++) {
		if (root[i].isObject()) {
			server_list.push_back(root[i]);
		}
	}

	return server_list;
}
Exemple #2
0
Json::Value getModstoreUrl(std::string url)
{
	std::vector<std::string> extra_headers;

	bool special_http_header = true;

	try {
		special_http_header = g_settings->getBool("modstore_disable_special_http_header");
	} catch (SettingNotFoundException) {}

	if (special_http_header) {
		extra_headers.push_back("Accept: application/vnd.minetest.mmdb-v1+json");
	}
	return fetchJsonValue(url, special_http_header ? &extra_headers : NULL);
}
Exemple #3
0
std::vector<ServerListSpec> getOnline()
{
	Json::Value root = fetchJsonValue(
			(g_settings->get("serverlist_url") + "/list").c_str(), NULL);

	std::vector<ServerListSpec> serverlist;

	if (root.isArray()) {
		for (unsigned int i = 0; i < root.size(); i++) {
			if (root[i].isObject()) {
				serverlist.push_back(root[i]);
			}
		}
	}

	return serverlist;
}
Exemple #4
0
Json::Value getModstoreUrl(std::string url)
{
	struct curl_slist *chunk = NULL;

	bool special_http_header = true;

	try{
		special_http_header = g_settings->getBool("modstore_disable_special_http_header");
	}
	catch(SettingNotFoundException &e) {
	}

	if (special_http_header)
		chunk = curl_slist_append(chunk, "Accept: application/vnd.minetest.mmdb-v1+json");

	Json::Value retval = fetchJsonValue(url,chunk);

	if (chunk != NULL)
		curl_slist_free_all(chunk);

	return retval;
}