2018-02-14 01:16:58 +00:00
|
|
|
#include <iostream>
|
2018-02-28 23:07:39 +00:00
|
|
|
#include <string>
|
2018-03-23 21:31:13 +00:00
|
|
|
#include <ctime>
|
2018-04-16 21:56:02 +00:00
|
|
|
#include <thread>
|
2018-02-15 23:09:09 +00:00
|
|
|
#include "sock/tcpsock.hpp"
|
2018-02-28 23:07:39 +00:00
|
|
|
#include "utils/string.hpp"
|
2018-03-01 23:16:47 +00:00
|
|
|
#include "utils/net.hpp"
|
2018-03-05 23:23:07 +00:00
|
|
|
#include "utils/time.hpp"
|
2018-03-07 23:07:28 +00:00
|
|
|
#include "sock/tcpsock.hpp"
|
2018-03-15 04:01:24 +00:00
|
|
|
#include "crypto/sha1.hpp"
|
2018-03-15 22:02:10 +00:00
|
|
|
#include "crypto/base64.hpp"
|
2018-03-20 22:42:26 +00:00
|
|
|
#include "crypto/bfish.hpp"
|
|
|
|
#include "utils/csprng.hpp"
|
2018-03-21 04:29:24 +00:00
|
|
|
#include "crypto/bcrypt.hpp"
|
2018-03-21 22:07:30 +00:00
|
|
|
#include "utils/bigint.hpp"
|
2018-04-02 20:33:01 +00:00
|
|
|
#include "sock/scapesock.hpp"
|
2018-04-12 21:50:21 +00:00
|
|
|
#include "sock/pool.hpp"
|
|
|
|
|
2018-04-16 21:56:02 +00:00
|
|
|
#include "hosts/master.hpp"
|
|
|
|
#include "hosts/slave.hpp"
|
|
|
|
|
|
|
|
bool master_intra(uint16_t port);
|
|
|
|
bool master_client(uint16_t port);
|
|
|
|
bool slave(uint16_t port);
|
2018-02-14 01:16:58 +00:00
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
2018-04-02 20:33:01 +00:00
|
|
|
sosc::ScapeServer server;
|
|
|
|
sosc::ScapeConnection client;
|
2018-03-29 22:10:39 +00:00
|
|
|
std::string buffer;
|
|
|
|
|
2018-04-02 20:33:01 +00:00
|
|
|
if(!server.Listen(8080)) {
|
|
|
|
std::cout << "Listening failed." << std::endl;
|
|
|
|
return -1;
|
|
|
|
}
|
2018-03-29 22:10:39 +00:00
|
|
|
std::cout << "Listening ..." << std::endl;
|
2018-04-02 20:33:01 +00:00
|
|
|
|
2018-04-04 13:14:32 +00:00
|
|
|
bool check = server.Accept(&client);
|
2018-04-02 20:33:01 +00:00
|
|
|
std::cout << "Shaking ..." << std::endl;
|
2018-03-29 22:10:39 +00:00
|
|
|
|
2018-04-02 20:33:01 +00:00
|
|
|
bool loop = true;
|
|
|
|
while(loop) {
|
2018-04-13 20:57:30 +00:00
|
|
|
if(!client.Handshaked())
|
2018-04-02 20:33:01 +00:00
|
|
|
client.Handshake();
|
2018-04-04 13:14:32 +00:00
|
|
|
else {
|
2018-04-04 22:01:20 +00:00
|
|
|
sosc::Packet pck;
|
|
|
|
client.Receive(&pck, true);
|
|
|
|
std::cout << pck.RegionCount() << std::endl;
|
2018-04-04 13:14:32 +00:00
|
|
|
}
|
2018-03-29 22:10:39 +00:00
|
|
|
}
|
2018-03-20 22:42:26 +00:00
|
|
|
|
2018-04-02 20:33:01 +00:00
|
|
|
server.Close();
|
2018-02-14 01:16:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2018-04-16 21:56:02 +00:00
|
|
|
|
|
|
|
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) {
|
|
|
|
|
|
|
|
}
|