X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/7897474c8a3fb975cc0bcda45e40c47d58959ea6..3b856e83ad55125111fe5961d07d7524bd6ee283:/projects/sgauthstress/proto.h diff --git a/projects/sgauthstress/proto.h b/projects/sgauthstress/proto.h index 05fe4722..543ae9e7 100644 --- a/projects/sgauthstress/proto.h +++ b/projects/sgauthstress/proto.h @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -31,7 +32,7 @@ class PROTO { const std::string GetStrError() const { return errorStr; } - void AddUser(const USER & user); + void AddUser(const USER & user, bool connect = false); bool Connect(uint32_t ip); bool Disconnect(uint32_t ip); @@ -43,13 +44,14 @@ class PROTO { struct sockaddr_in serverAddr; int timeout; - std::vector > users; + std::list > users; std::vector pollFds; bool running; bool stopped; pthread_t tid; + pthread_mutex_t mutex; std::string errorStr; @@ -58,9 +60,10 @@ class PROTO { static void * Runner(void * data); void Run(); + void CheckTimeouts(); bool RecvPacket(); bool SendPacket(const void * buffer, size_t length, USER * user); - bool HandlePacket(const char * buffer, USER * user); + bool HandlePacket(const char * buffer, size_t length, USER * user); bool CONN_SYN_ACK_Proc(const void * buffer, USER * user); bool ALIVE_SYN_Proc(const void * buffer, USER * user); @@ -74,6 +77,9 @@ class PROTO { bool Send_DISCONN_SYN(USER * user); bool Send_DISCONN_ACK(USER * user); bool Send_ALIVE_ACK(USER * user); + + bool RealConnect(USER * user); + bool RealDisconnect(USER * user); }; #endif