From 8fdb38e494313448f8d21f93974070b08f5638e8 Mon Sep 17 00:00:00 2001 From: Alec Obradovich Date: Thu, 20 Dec 2018 13:57:26 -0600 Subject: [PATCH] things a long time ago that i forgot --- src/server/common.hpp | 7 +++++++ src/server/hosts/slave.cpp | 10 +++++++--- src/server/hosts/slave.hpp | 18 ++++-------------- src/server/main.cpp | 7 +++++-- src/web/script.js | 2 +- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/server/common.hpp b/src/server/common.hpp index f334060..cc803d1 100644 --- a/src/server/common.hpp +++ b/src/server/common.hpp @@ -1,6 +1,7 @@ #ifndef SOSC_SERVER_COMMON_H #define SOSC_SERVER_COMMON_H +#include "utils/ini.hpp" #include #ifdef SOSC_DEBUG @@ -11,4 +12,10 @@ #define SOSC_RESC(X) (SOSC_RESOURCE_PATH + std::string(X)) +namespace sosc { +struct { + ini::File* config = nullptr; +} _global_ctx; +} + #endif diff --git a/src/server/hosts/slave.cpp b/src/server/hosts/slave.cpp index b95c3bb..b9f4d13 100644 --- a/src/server/hosts/slave.cpp +++ b/src/server/hosts/slave.cpp @@ -1,5 +1,12 @@ #include "slave.hpp" +/** SLAVE -> MASTER **/ + +bool sosc::slave_to_master_thread(IntraClient* client) { + *client = IntraClient(); + client->Open(); +} + /** SLAVE -> CLIENT **/ sosc::SlaveClient::SlaveClient(const ScapeConnection& client) { @@ -15,6 +22,3 @@ bool sosc::SlaveClient::Close(const Packet& message) { this->sock.Send(message); return this->Close(); } - -/** SLAVE -> MASTER **/ - diff --git a/src/server/hosts/slave.hpp b/src/server/hosts/slave.hpp index aaaf592..ad3c297 100644 --- a/src/server/hosts/slave.hpp +++ b/src/server/hosts/slave.hpp @@ -7,6 +7,10 @@ #include "ctx/slave.hpp" namespace sosc { +/** SLAVE -> MASTER **/ + +bool slave_to_master_thread(IntraClient* client); + /** SLAVE -> CLIENT **/ class SlaveClient { @@ -33,20 +37,6 @@ protected: return true; } }; - -/** SLAVE -> MASTER **/ - -class SlaveMaster { -public: - SlaveMaster(); - - - - bool Close(); - bool Close(const Packet& message); -private: - IntraClient sock; -}; } #endif diff --git a/src/server/main.cpp b/src/server/main.cpp index b27015d..dff421c 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -4,6 +4,7 @@ #include #include +#include "common.hpp" #include "db/database.hpp" #include "hosts/master.hpp" #include "hosts/slave.hpp" @@ -66,9 +67,8 @@ void configure_poolinfo(sosc::poolinfo_t* info, int main(int argc, char **argv) { using namespace sosc; - ini::File* config; try { - config = ini::File::Open(SOSC_RESC("config.ini"), { + _global_ctx.config = ini::File::Open(SOSC_RESC("config.ini"), { ini::Rule("general", true, false, { ini::Field("run master", ini::Field::BOOL), ini::Field("master host", ini::Field::STRING), @@ -101,6 +101,7 @@ int main(int argc, char **argv) { return -1; } + ini::File* config = _global_ctx.config; poolinfo_t info; configure_poolinfo(&_ctx.default_info, (*config)["pool defaults"][0]); @@ -221,6 +222,8 @@ bool slave_start(uint16_t port, const sosc::poolinfo_t& info, slave_ctx* ctx) { return true; } + + void master_intra_stop() { if(_ctx.master_intra == nullptr) return; diff --git a/src/web/script.js b/src/web/script.js index ee2b9dd..3aa43f9 100644 --- a/src/web/script.js +++ b/src/web/script.js @@ -110,7 +110,7 @@ function attempt_register() { error.classList.remove("hidden"); } else { alert("Registration was successful."); - show_section("servers"); + show_section("login"); refresh_list(); }