X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/6ce56fd8481f4fc5ae2cf9383e6b6ecbff42b41d..d53db9f84ce3a75fc6c14e0b595ab9890c70145f:/projects/sgauthstress/proto.h?ds=sidebyside diff --git a/projects/sgauthstress/proto.h b/projects/sgauthstress/proto.h index f478c0e1..0a2fb2de 100644 --- a/projects/sgauthstress/proto.h +++ b/projects/sgauthstress/proto.h @@ -3,8 +3,10 @@ #include #include +#include #include +#include #include #include "stg/os_int.h" @@ -14,7 +16,7 @@ class PROTO; -typedef bool (PROTO::*PacketProcessor)(char *); +typedef bool (PROTO::*PacketProcessor)(const void *, USER *); class PROTO { public: @@ -29,16 +31,18 @@ class PROTO { const std::string GetStrError() const { return errorStr; } - bool Connect(const std::string & login); - bool Disconnect(const std::string & login); + void AddUser(const USER & user); + + bool Connect(uint32_t ip); + bool Disconnect(uint32_t ip); private: - int sock; BLOWFISH_CTX ctx; struct sockaddr_in localAddr; struct sockaddr_in serverAddr; int timeout; - std::map users; + std::vector > users; + std::vector pollFds; bool running; bool stopped; @@ -53,14 +57,21 @@ class PROTO { void Run(); bool RecvPacket(); - bool HandlePacket(char * buffer); - - bool CONN_SYN_ACK_Proc(char * buffer); - bool ALIVE_SYN_Proc(char * buffer); - bool DISCONN_SYN_ACK_Proc(char * buffer); - bool FIN_Proc(char * buffer); - bool INFO_Proc(char * buffer); - bool ERR_Proc(char * buffer); + bool SendPacket(const void * buffer, size_t length, USER * user); + bool HandlePacket(const char * buffer, USER * user); + + bool CONN_SYN_ACK_Proc(const void * buffer, USER * user); + bool ALIVE_SYN_Proc(const void * buffer, USER * user); + bool DISCONN_SYN_ACK_Proc(const void * buffer, USER * user); + bool FIN_Proc(const void * buffer, USER * user); + bool INFO_Proc(const void * buffer, USER * user); + bool ERR_Proc(const void * buffer, USER * user); + + bool Send_CONN_SYN(USER * user); + bool Send_CONN_ACK(USER * user); + bool Send_DISCONN_SYN(USER * user); + bool Send_DISCONN_ACK(USER * user); + bool Send_ALIVE_ACK(USER * user); }; #endif