diff --git a/server/src/hosts/master.hpp b/server/src/hosts/master.hpp new file mode 100644 index 0000000..30ac4fb --- /dev/null +++ b/server/src/hosts/master.hpp @@ -0,0 +1,38 @@ +#ifndef SOSC_HOST_MASTER_H +#define SOSC_HOST_MASTER_H + +#include "../sock/intrasock.hpp" +#include "../sock/scapesock.hpp" +#include "../sock/pool.hpp" + +namespace sosc { +/** MASTER -> CLIENT **/ + +class MasterClient { +public: + +private: + ScapeConnection sock; +}; + +class MasterClientPool : public Pool { +protected: + bool ProcessClient(MasterClient* client) override; +}; + +/** MASTER -> SLAVE **/ + +class MasterIntra { +public: + MasterIntra(IntraClient client); +private: + IntraClient sock; +}; + +class MasterIntraPool : public Pool { +protected: + bool ProcessClient(MasterIntra* client) override; +}; +} + +#endif diff --git a/server/src/hosts/master_client.cpp b/server/src/hosts/master_client.cpp new file mode 100644 index 0000000..2092c57 --- /dev/null +++ b/server/src/hosts/master_client.cpp @@ -0,0 +1,2 @@ +#include "master.hpp" + diff --git a/server/src/hosts/master_intra.cpp b/server/src/hosts/master_intra.cpp new file mode 100644 index 0000000..2092c57 --- /dev/null +++ b/server/src/hosts/master_intra.cpp @@ -0,0 +1,2 @@ +#include "master.hpp" + diff --git a/server/src/hosts/slave.cpp b/server/src/hosts/slave.cpp new file mode 100644 index 0000000..53b4040 --- /dev/null +++ b/server/src/hosts/slave.cpp @@ -0,0 +1,5 @@ +#include "slave.hpp" + +bool sosc::SlavePool::ProcessClient(SlaveClient* client) { + return true; +} diff --git a/server/src/hosts/slave.hpp b/server/src/hosts/slave.hpp new file mode 100644 index 0000000..124347c --- /dev/null +++ b/server/src/hosts/slave.hpp @@ -0,0 +1,21 @@ +#ifndef SOSC_HOST_SLAVE_H +#define SOSC_HOST_SLAVE_H + +#include "../sock/scapesock.hpp" +#include "../sock/pool.hpp" + +namespace sosc { +class SlaveClient { +public: + +private: + ScapeConnection sock; +}; + +class SlavePool : public Pool { +protected: + bool ProcessClient(SlaveClient* client) override; +}; +} + +#endif diff --git a/server/src/main.cpp b/server/src/main.cpp index 73dcea5..2697b4f 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "sock/tcpsock.hpp" #include "utils/string.hpp" #include "utils/net.hpp" @@ -15,11 +16,18 @@ #include "sock/scapesock.hpp" #include "sock/pool.hpp" -class User; +#include "hosts/master.hpp" +#include "hosts/slave.hpp" + +/*class User; class Test : sosc::Pool { protected: bool ProcessClient(User* client) override; -}; +};*/ + +bool master_intra(uint16_t port); +bool master_client(uint16_t port); +bool slave(uint16_t port); int main(int argc, char **argv) { sosc::ScapeServer server; @@ -49,3 +57,33 @@ int main(int argc, char **argv) { server.Close(); return 0; } + +bool master_intra(uint16_t port, sosc::poolinfo_t info) { + using namespace sosc; + + IntraServer server; + IntraClient client; + if(!server.Listen(port)) + return false; + + MasterIntraPool pool; + pool.Configure(info); + pool.Start(); + + while(server.Accept(&client)) + pool.AddClient(MasterIntra(client)); + + return true; +} + +bool master_client(uint16_t port, sosc::poolinfo_t info) { + /* + auto pooler = std::thread([&]() { + + }); + */ +} + +bool slave(uint16_t port, sosc::poolinfo_t info) { + +} diff --git a/server/src/sock/pool.hpp b/server/src/sock/pool.hpp index 04ca9d9..57d0e31 100644 --- a/server/src/sock/pool.hpp +++ b/server/src/sock/pool.hpp @@ -29,7 +29,8 @@ typedef struct { template class Pool { public: - Pool(const poolinfo_t& info); + Pool(); + void Configure(const poolinfo_t& info); void Start(); bool AddClient(T* client); @@ -78,7 +79,12 @@ private: }; template -Pool::Pool(const poolinfo_t& info) { +Pool::Pool() { + this->info = poolinfo_t(); +} + +template +void Pool::Configure(const poolinfo_t& info) { this->info = info; this->is_running = false; } @@ -116,7 +122,7 @@ bool Pool::CanAddStack() const { template bool Pool::AddClient(T* client) { if(!this->is_running) - return; + return false; if(this->info.max_total != -1) if(this->ClientCount() >= this->info.max_total)