X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/7adae1923ee7cde74ee96f762c994ecafa0e1ca4..43e405c1473de38b677d9a228fea4df415037bb1:/projects/sgauthstress/main.cpp diff --git a/projects/sgauthstress/main.cpp b/projects/sgauthstress/main.cpp index 3d0adb49..c7e69c4a 100644 --- a/projects/sgauthstress/main.cpp +++ b/projects/sgauthstress/main.cpp @@ -35,6 +35,7 @@ #include "settings.h" #include "store_loader.h" +#include "proto.h" #include "user.h" time_t stgTime; @@ -94,6 +95,17 @@ if (settings.ReadSettings()) SetSignalHandlers(); +PROTO proto(settings.GetServerName(), + settings.GetServerPort(), + settings.GetLocalPort(), + 1000); + +if (!proto.Start()) + { + std::cerr << "Failed to start listening thread: '" << proto.GetStrError() << "'" << std::endl; + return -1; + } + STORE_LOADER storeLoader(settings.GetModulesPath(), settings.GetStoreModuleSettings()); if (storeLoader.Load()) { @@ -110,7 +122,6 @@ if (dataStore->GetUsersList(&userList)) return -1; } -std::vector users; std::vector::const_iterator it; for (it = userList.begin(); it != userList.end(); ++it) { @@ -120,18 +131,17 @@ for (it = userList.begin(); it != userList.end(); ++it) std::cerr << "Failed to read user conf: '" << dataStore->GetStrError() << "'" << std::endl; return -1; } - users.push_back( + proto.AddUser( USER( - settings.GetServerName(), - settings.GetServerPort(), - settings.GetLocalPort(), *it, - userConf.password - ) + userConf.password, + userConf.ips[0].ip + ), + true ); } -std::cout << "Successfully loaded " << users.size() << " users" << std::endl; +std::cout << "Successfully loaded " << proto.UserCount() << " users" << std::endl; running = true; while (running) @@ -139,6 +149,8 @@ while (running) usleep(200000); } +proto.Stop(); + storeLoader.Unload(); return 0;