slave boob
This commit is contained in:
parent
8976efe29b
commit
9baa9a73a4
7 changed files with 117 additions and 5 deletions
38
server/src/hosts/master.hpp
Normal file
38
server/src/hosts/master.hpp
Normal file
|
@ -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<MasterClient> {
|
||||||
|
protected:
|
||||||
|
bool ProcessClient(MasterClient* client) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** MASTER -> SLAVE **/
|
||||||
|
|
||||||
|
class MasterIntra {
|
||||||
|
public:
|
||||||
|
MasterIntra(IntraClient client);
|
||||||
|
private:
|
||||||
|
IntraClient sock;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MasterIntraPool : public Pool<MasterIntra> {
|
||||||
|
protected:
|
||||||
|
bool ProcessClient(MasterIntra* client) override;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
2
server/src/hosts/master_client.cpp
Normal file
2
server/src/hosts/master_client.cpp
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#include "master.hpp"
|
||||||
|
|
2
server/src/hosts/master_intra.cpp
Normal file
2
server/src/hosts/master_intra.cpp
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#include "master.hpp"
|
||||||
|
|
5
server/src/hosts/slave.cpp
Normal file
5
server/src/hosts/slave.cpp
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#include "slave.hpp"
|
||||||
|
|
||||||
|
bool sosc::SlavePool::ProcessClient(SlaveClient* client) {
|
||||||
|
return true;
|
||||||
|
}
|
21
server/src/hosts/slave.hpp
Normal file
21
server/src/hosts/slave.hpp
Normal file
|
@ -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<SlaveClient> {
|
||||||
|
protected:
|
||||||
|
bool ProcessClient(SlaveClient* client) override;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <thread>
|
||||||
#include "sock/tcpsock.hpp"
|
#include "sock/tcpsock.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
#include "utils/net.hpp"
|
#include "utils/net.hpp"
|
||||||
|
@ -15,11 +16,18 @@
|
||||||
#include "sock/scapesock.hpp"
|
#include "sock/scapesock.hpp"
|
||||||
#include "sock/pool.hpp"
|
#include "sock/pool.hpp"
|
||||||
|
|
||||||
class User;
|
#include "hosts/master.hpp"
|
||||||
|
#include "hosts/slave.hpp"
|
||||||
|
|
||||||
|
/*class User;
|
||||||
class Test : sosc::Pool<User> {
|
class Test : sosc::Pool<User> {
|
||||||
protected:
|
protected:
|
||||||
bool ProcessClient(User* client) override;
|
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) {
|
int main(int argc, char **argv) {
|
||||||
sosc::ScapeServer server;
|
sosc::ScapeServer server;
|
||||||
|
@ -49,3 +57,33 @@ int main(int argc, char **argv) {
|
||||||
server.Close();
|
server.Close();
|
||||||
return 0;
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ typedef struct {
|
||||||
template<class T>
|
template<class T>
|
||||||
class Pool {
|
class Pool {
|
||||||
public:
|
public:
|
||||||
Pool(const poolinfo_t& info);
|
Pool();
|
||||||
|
void Configure(const poolinfo_t& info);
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
bool AddClient(T* client);
|
bool AddClient(T* client);
|
||||||
|
@ -78,7 +79,12 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
Pool<T>::Pool(const poolinfo_t& info) {
|
Pool<T>::Pool() {
|
||||||
|
this->info = poolinfo_t();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void Pool<T>::Configure(const poolinfo_t& info) {
|
||||||
this->info = info;
|
this->info = info;
|
||||||
this->is_running = false;
|
this->is_running = false;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +122,7 @@ bool Pool<T>::CanAddStack() const {
|
||||||
template<class T>
|
template<class T>
|
||||||
bool Pool<T>::AddClient(T* client) {
|
bool Pool<T>::AddClient(T* client) {
|
||||||
if(!this->is_running)
|
if(!this->is_running)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if(this->info.max_total != -1)
|
if(this->info.max_total != -1)
|
||||||
if(this->ClientCount() >= this->info.max_total)
|
if(this->ClientCount() >= this->info.max_total)
|
||||||
|
|
Loading…
Reference in a new issue