things a long time ago that i forgot

This commit is contained in:
Alec Obradovich 2018-12-20 13:57:26 -06:00
parent 45c471c143
commit 8fdb38e494
5 changed files with 24 additions and 20 deletions

View file

@ -1,6 +1,7 @@
#ifndef SOSC_SERVER_COMMON_H #ifndef SOSC_SERVER_COMMON_H
#define SOSC_SERVER_COMMON_H #define SOSC_SERVER_COMMON_H
#include "utils/ini.hpp"
#include <string> #include <string>
#ifdef SOSC_DEBUG #ifdef SOSC_DEBUG
@ -11,4 +12,10 @@
#define SOSC_RESC(X) (SOSC_RESOURCE_PATH + std::string(X)) #define SOSC_RESC(X) (SOSC_RESOURCE_PATH + std::string(X))
namespace sosc {
struct {
ini::File* config = nullptr;
} _global_ctx;
}
#endif #endif

View file

@ -1,5 +1,12 @@
#include "slave.hpp" #include "slave.hpp"
/** SLAVE -> MASTER **/
bool sosc::slave_to_master_thread(IntraClient* client) {
*client = IntraClient();
client->Open();
}
/** SLAVE -> CLIENT **/ /** SLAVE -> CLIENT **/
sosc::SlaveClient::SlaveClient(const ScapeConnection& client) { sosc::SlaveClient::SlaveClient(const ScapeConnection& client) {
@ -15,6 +22,3 @@ bool sosc::SlaveClient::Close(const Packet& message) {
this->sock.Send(message); this->sock.Send(message);
return this->Close(); return this->Close();
} }
/** SLAVE -> MASTER **/

View file

@ -7,6 +7,10 @@
#include "ctx/slave.hpp" #include "ctx/slave.hpp"
namespace sosc { namespace sosc {
/** SLAVE -> MASTER **/
bool slave_to_master_thread(IntraClient* client);
/** SLAVE -> CLIENT **/ /** SLAVE -> CLIENT **/
class SlaveClient { class SlaveClient {
@ -33,20 +37,6 @@ protected:
return true; return true;
} }
}; };
/** SLAVE -> MASTER **/
class SlaveMaster {
public:
SlaveMaster();
bool Close();
bool Close(const Packet& message);
private:
IntraClient sock;
};
} }
#endif #endif

View file

@ -4,6 +4,7 @@
#include <thread> #include <thread>
#include <sock/pool.hpp> #include <sock/pool.hpp>
#include "common.hpp"
#include "db/database.hpp" #include "db/database.hpp"
#include "hosts/master.hpp" #include "hosts/master.hpp"
#include "hosts/slave.hpp" #include "hosts/slave.hpp"
@ -66,9 +67,8 @@ void configure_poolinfo(sosc::poolinfo_t* info,
int main(int argc, char **argv) { int main(int argc, char **argv) {
using namespace sosc; using namespace sosc;
ini::File* config;
try { 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::Rule("general", true, false, {
ini::Field("run master", ini::Field::BOOL), ini::Field("run master", ini::Field::BOOL),
ini::Field("master host", ini::Field::STRING), ini::Field("master host", ini::Field::STRING),
@ -101,6 +101,7 @@ int main(int argc, char **argv) {
return -1; return -1;
} }
ini::File* config = _global_ctx.config;
poolinfo_t info; poolinfo_t info;
configure_poolinfo(&_ctx.default_info, (*config)["pool defaults"][0]); 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; return true;
} }
void master_intra_stop() { void master_intra_stop() {
if(_ctx.master_intra == nullptr) if(_ctx.master_intra == nullptr)
return; return;

View file

@ -110,7 +110,7 @@ function attempt_register() {
error.classList.remove("hidden"); error.classList.remove("hidden");
} else { } else {
alert("Registration was successful."); alert("Registration was successful.");
show_section("servers"); show_section("login");
refresh_list(); refresh_list();
} }