things a long time ago that i forgot
This commit is contained in:
parent
45c471c143
commit
8fdb38e494
5 changed files with 24 additions and 20 deletions
|
@ -1,6 +1,7 @@
|
|||
#ifndef SOSC_SERVER_COMMON_H
|
||||
#define SOSC_SERVER_COMMON_H
|
||||
|
||||
#include "utils/ini.hpp"
|
||||
#include <string>
|
||||
|
||||
#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
|
||||
|
|
|
@ -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 **/
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <thread>
|
||||
#include <sock/pool.hpp>
|
||||
|
||||
#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;
|
||||
|
|
|
@ -110,7 +110,7 @@ function attempt_register() {
|
|||
error.classList.remove("hidden");
|
||||
} else {
|
||||
alert("Registration was successful.");
|
||||
show_section("servers");
|
||||
show_section("login");
|
||||
refresh_list();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue