1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-10 19:32:10 +00:00

Basic Lan Implmentation

This commit is contained in:
DustyBagel 2024-06-21 16:33:44 -05:00
parent bc23a610d3
commit f03922f218
26 changed files with 1414 additions and 2 deletions

View file

@ -28,9 +28,45 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "convert_json.h"
#include "httpfetch.h"
#include "server.h"
#include "network/lan.h"
#include "json/json.h"
namespace ServerList
{
/*
Special thanks to proller <proler@gmail.com> for
letting us use the methods lan_get() and lan_fresh()
as well as the lan_adv class.
*/
static std::string ask_str;
lan_adv lan_adv_client;
void lan_get() {
if (!g_settings->getBool("serverlist_lan"))
return;
lan_adv_client.ask();
}
/*
if (ask_str.empty()) {
Json::Value j;
j["cmd"] = "ask";
j["proto_min"] = Server::getProtocolVersionMin();
j["proto_max"] = Server::getProtocolVersionMax();
ask_str = fastWriteJson(j);
};
lan_adv_client.send_string(ask_str);
*/
bool lan_fresh() {
auto result = lan_adv_client.fresh.load();
lan_adv_client.fresh = false;
return result;
}
#if USE_CURL
void sendAnnounce(AnnounceAction action,
const u16 port,

View file

@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content/mods.h"
#include "json-forwards.h"
#include <iostream>
#include "network/lan.h"
#pragma once
@ -28,6 +29,15 @@ with this program; if not, write to the Free Software Foundation, Inc.,
namespace ServerList
{
/*
Special thanks to proller <proler@gmail.com> for
letting us use the methods lan_get() and lan_fresh()
as well as the lan_adv class.
*/
extern lan_adv lan_adv_client;
void lan_get();
bool lan_fresh();
#if USE_CURL
enum AnnounceAction {AA_START, AA_UPDATE, AA_DELETE};
void sendAnnounce(AnnounceAction, u16 port,