fully implement lua

This commit is contained in:
Lion Kortlepel
2021-02-16 12:03:23 +01:00
committed by Anonymous275
parent 459814a6ec
commit 4cda6e8bc3
12 changed files with 252 additions and 234 deletions

View File

@@ -3,6 +3,7 @@
#include "IThreaded.h"
#include "TConfig.h"
#include "TConsole.h"
#include "TLuaEngine.h"
#include "TServer.h"
#include <atomic>
#include <functional>
@@ -25,13 +26,16 @@ void UnixSignalHandler(int sig) {
info("gracefully shutting down via SIGINT");
Application::GracefullyShutdown();
break;
default:
debug("unhandled signal: " + std::to_string(sig));
break;
}
}
#endif // __unix
int main(int argc, char** argv) {
#ifdef __unix
info("registering SIGPIPE and SIGTERM handlers");
info("registering handlers for SIGINT, SIGTERM, SIGPIPE");
signal(SIGPIPE, UnixSignalHandler);
signal(SIGTERM, UnixSignalHandler);
signal(SIGINT, UnixSignalHandler);
@@ -39,20 +43,9 @@ int main(int argc, char** argv) {
TServer Server(argc, argv);
TConfig Config("Server.cfg");
TLuaEngine LuaEngine(Server);
auto Client = Server.InsertNewClient();
if (!Client.expired()) {
Client.lock()->SetName("Lion");
} else {
error("fuckj");
_Exit(-1);
}
Server.ForEachClient([](auto client) -> bool { debug(client.lock()->GetName()); return true; });
Server.RemoveClient(Client);
// TODO: replace with blocking heartbeat
// TODO: replace
bool Shutdown = false;
Application::RegisterShutdownHandler([&Shutdown] { Shutdown = true; });
while (!Shutdown) {