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:
parent
bc23a610d3
commit
f03922f218
26 changed files with 1414 additions and 2 deletions
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue