#include #include #include #include using namespace std; using namespace std::chrono; using namespace license; /* struct LicenseInfo { LicenseType type; std::string username; std::string first_name; std::string last_name; std::string email; std::chrono::system_clock::time_point start; std::chrono::system_clock::time_point end; std::chrono::system_clock::time_point creation; inline bool isValid() { return (end.time_since_epoch().count() == 0 || std::chrono::system_clock::now() < this->end); } }; */ int main(int ac, char** av){ auto state = evthread_use_pthreads(); assert(state == 0); srand(system_clock::now().time_since_epoch().count()); cout << "Generating new license" << endl; std::string name = "WolverinDEV"; auto raw_license = createLocalLicence(LicenseType::PREMIUM, system_clock::now() - chrono::hours((int) (24 * 30.5 * 3)), "WolverinDEV"); auto license = readLocalLicence(raw_license, error); assert(license); sockaddr_in serv_addr{}; serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = ((in_addr*) gethostbyname("localhost")->h_addr)->s_addr; serv_addr.sin_port = htons(27786); /* * struct LicenseRequestData { std::shared_ptr license; int64_t speach_total; int64_t speach_dead; int64_t speach_online; int64_t speach_varianz; int64_t client_online; int64_t bots_online; int64_t queries_online; int64_t servers_online; }; */ auto data = make_shared(); data->license = license; data->info = make_shared(); while(true) { LicenceRequest request(data, serv_addr); try { cout << "Requesting license" << endl; auto info = request.requestInfo().waitAndGet(nullptr); if(!info) { cout << "Invalid result! Error: " << (request.exception() ? "yes => " + string(request.exception()->what()) : "no") << endl; throw *request.exception(); } cout << "Got result!" << endl; cout << "Valid: " << info->license_valid << endl; if(info->license) { cout << "License:" << endl; cout << " Type: " << info->license->type << endl; cout << " User name: " << info->license->username << endl; cout << " First name: " << info->license->first_name << endl; cout << " Last name: " << info->license->last_name << endl; cout << " EMail: " << info->license->email << endl; } else cout << "License: none"; } catch (const std::exception& ex){ cerr << "Could not load info after throwing: " << endl << ex.what() << endl; } } return 0; }