X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/3886ef930e3fd54894b8798ab17ef4d3bc0b995a..9d093a68b5f3e5a22e243c92ec2e0bd24b10ea38:/projects/stargazer/plugins/configuration/sgconfig-ng/main_thread.h diff --git a/projects/stargazer/plugins/configuration/sgconfig-ng/main_thread.h b/projects/stargazer/plugins/configuration/sgconfig-ng/main_thread.h new file mode 100644 index 00000000..d3ec96c0 --- /dev/null +++ b/projects/stargazer/plugins/configuration/sgconfig-ng/main_thread.h @@ -0,0 +1,56 @@ +#ifndef __MAIN_THREAD_H__ +#define __MAIN_THREAD_H__ + +#include + +#include "os_int.h" + +class CONFIG_THREAD; +class ADMINS; +class TARIFFS; +class USERS; +class SETTINGS; + +class MAIN_THREAD { +public: + MAIN_THREAD(ADMINS * a, TARIFFS * t, USERS * u, const SETTINGS * s); + ~MAIN_THREAD(); + + void operator() (); + + void Stop() { running = false; }; + void SetPort(uint16_t p) { port = p; }; + void SetClasses(ADMINS * a, + TARIFFS * t, + USERS * u, + const SETTINGS * s) + { + admins = a; + tariffs = t; + users = u; + settings = s; + }; + + void SetMaxConnections(unsigned max) { maxConnections = max; }; + +private: + bool running; + int sd; + uint16_t port; + unsigned maxConnections; + + ADMINS * admins; + TARIFFS * tariffs; + USERS * users; + const SETTINGS * settings; + + std::list connections; + + bool InitNetwork(); + bool WaitConnection(); + void AcceptConnection(); + void CleanupThreads(); + +}; + +#endif