smol
This commit is contained in:
parent
8e56fec1a9
commit
c5c1441287
5 changed files with 43 additions and 38 deletions
|
@ -26,6 +26,7 @@ private:
|
||||||
|
|
||||||
class MasterClientPool : public Pool<MasterClient> {
|
class MasterClientPool : public Pool<MasterClient> {
|
||||||
protected:
|
protected:
|
||||||
|
void SetupQueries(Queries* queries) override;
|
||||||
bool ProcessClient(MasterClient& client, const Queries* queries) override {
|
bool ProcessClient(MasterClient& client, const Queries* queries) override {
|
||||||
// TODO implement
|
// TODO implement
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,2 +1,9 @@
|
||||||
#include "master.hpp"
|
#include "master.hpp"
|
||||||
|
|
||||||
|
/** MASTERCLIENTPOOL CODE **/
|
||||||
|
|
||||||
|
void sosc::MasterClientPool::SetupQueries(Queries *queries) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** MASTERCLIENT CODE **/
|
|
@ -9,14 +9,14 @@ namespace sosc {
|
||||||
|
|
||||||
class SlaveClient {
|
class SlaveClient {
|
||||||
public:
|
public:
|
||||||
SlaveClient(const ScapeConnection& client);
|
explicit SlaveClient(const ScapeConnection& client);
|
||||||
private:
|
private:
|
||||||
ScapeConnection sock;
|
ScapeConnection sock;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SlaveClientPool : Pool<SlaveClient*> {
|
class SlaveClientPool : public Pool<SlaveClient> {
|
||||||
protected:
|
protected:
|
||||||
bool ProcessClient(SlaveClient*& client) override {
|
bool ProcessClient(SlaveClient& client, const Queries* queries) override {
|
||||||
// TODO implement
|
// TODO implement
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,36 +19,20 @@
|
||||||
#include "hosts/master.hpp"
|
#include "hosts/master.hpp"
|
||||||
#include "hosts/slave.hpp"
|
#include "hosts/slave.hpp"
|
||||||
|
|
||||||
bool master_intra(uint16_t port);
|
bool master_intra(uint16_t port, const sosc::poolinfo_t& info);
|
||||||
bool master_client(uint16_t port);
|
bool master_client(uint16_t port, const sosc::poolinfo_t& info);
|
||||||
bool slave(uint16_t port);
|
bool slave(uint16_t port, const sosc::poolinfo_t& info);
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
sosc::ScapeServer server;
|
if(argc < 2)
|
||||||
sosc::ScapeConnection client;
|
|
||||||
std::string buffer;
|
|
||||||
|
|
||||||
if(!server.Listen(8080)) {
|
|
||||||
std::cout << "Listening failed." << std::endl;
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if(argv[1][0] == 'm') {
|
||||||
|
master_intra(1234, sosc::poolinfo_t());
|
||||||
|
} else {
|
||||||
|
slave(1234, sosc::poolinfo_t());
|
||||||
}
|
}
|
||||||
std::cout << "Listening ..." << std::endl;
|
|
||||||
|
|
||||||
bool check = server.Accept(&client);
|
|
||||||
std::cout << "Shaking ..." << std::endl;
|
|
||||||
|
|
||||||
bool loop = true;
|
|
||||||
while(loop) {
|
|
||||||
if(!client.Handshaked())
|
|
||||||
client.Handshake();
|
|
||||||
else {
|
|
||||||
sosc::Packet pck;
|
|
||||||
client.Receive(&pck, true);
|
|
||||||
std::cout << pck.RegionCount() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
server.Close();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,17 +55,29 @@ bool master_intra(uint16_t port, const sosc::poolinfo_t& info) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool master_client(uint16_t port, sosc::poolinfo_t info) {
|
bool master_client(uint16_t port, const sosc::poolinfo_t& info) {
|
||||||
/*
|
using namespace sosc;
|
||||||
auto pooler = std::thread([&]() {
|
|
||||||
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool slave(uint16_t port, sosc::poolinfo_t info) {
|
bool slave(uint16_t port, const sosc::poolinfo_t& info) {
|
||||||
|
using namespace sosc;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ScapeServer server;
|
||||||
|
ScapeConnection client;
|
||||||
|
if(!server.Listen(port))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SlaveClientPool pool;
|
||||||
|
pool.Configure(info);
|
||||||
|
pool.Start();
|
||||||
|
|
||||||
|
while(server.Accept(&client))
|
||||||
|
pool.AddClient(SlaveClient(client));
|
||||||
|
|
||||||
|
pool.Stop();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ bool sosc::ScapeConnection::IsCiphered() const {
|
||||||
|
|
||||||
void sosc::ScapeConnection::SetCipher(cgc::Cipher* cipher) {
|
void sosc::ScapeConnection::SetCipher(cgc::Cipher* cipher) {
|
||||||
this->cipher = cipher;
|
this->cipher = cipher;
|
||||||
|
cipher->Parse(&this->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sosc::ScapeConnection::Handshake() {
|
int sosc::ScapeConnection::Handshake() {
|
||||||
|
|
Loading…
Reference in a new issue