Merge TUDPServer and TTCPServer into TNetwork

this gets rid of a bunch of unclear cases which I mistakenly created
while refactoring for this rewrite. One example is having to call into
TTCPServer to do UDP sending in some cases.
This commit is contained in:
Lion Kortlepel
2021-03-08 23:45:25 +01:00
committed by Anonymous275
parent 05c5fb047c
commit 40cae31885
15 changed files with 378 additions and 451 deletions

View File

@@ -4,15 +4,14 @@
#include "IThreaded.h"
#include "TLuaFile.h"
#include "TServer.h"
#include <optional>
#include <lua.hpp>
#include <memory>
#include <optional>
#include <set>
class TLuaEngine : public IThreaded {
public:
explicit TLuaEngine(TServer& Server, TTCPServer& TCPServer, TUDPServer& UDPServer);
//~TLuaEngine();
explicit TLuaEngine(TServer& Server, TNetwork& Network);
using TSetOfLuaFile = std::set<std::unique_ptr<TLuaFile>>;
@@ -21,19 +20,17 @@ public:
[[nodiscard]] const TSetOfLuaFile& LuaFiles() const { return mLuaFiles; }
[[nodiscard]] TServer& Server() { return mServer; }
[[nodiscard]] const TServer& Server() const { return mServer; }
[[nodiscard]] TNetwork& Network() { return mNetwork; }
[[nodiscard]] const TNetwork& Network() const { return mNetwork; }
std::optional<std::reference_wrapper<TLuaFile>> GetScript(lua_State* L);
TTCPServer& TCPServer() { return mTCPServer; }
TUDPServer& UDPServer() { return mUDPServer; }
private:
void FolderList(const std::string& Path, bool HotSwap);
void RegisterFiles(const std::string& Path, bool HotSwap);
bool NewFile(const std::string& Path);
TTCPServer& mTCPServer;
TUDPServer& mUDPServer;
TNetwork& mNetwork;
TServer& mServer;
std::string mPath;
bool mShutdown { false };