From a5acd4c9a3b24c9d5af3a8f504e5af053fa7fa09 Mon Sep 17 00:00:00 2001 From: boris Date: Thu, 20 Dec 2018 21:38:04 +1300 Subject: yo is this loss --- csgo-loader/csgo-server/Networking/TCPServer.hpp | 26 ++++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'csgo-loader/csgo-server/Networking/TCPServer.hpp') diff --git a/csgo-loader/csgo-server/Networking/TCPServer.hpp b/csgo-loader/csgo-server/Networking/TCPServer.hpp index adb6e7c..388bdc2 100644 --- a/csgo-loader/csgo-server/Networking/TCPServer.hpp +++ b/csgo-loader/csgo-server/Networking/TCPServer.hpp @@ -16,16 +16,19 @@ // std::thread #include -namespace Networking { +namespace Networking +{ // Base connection class, used to handle multiple connections in a thread-based model. - class TCPConnection { + class TCPConnection + { SOCKET m_Socket; Wrapper::Encryption m_Encryption; const char *m_IpAddress; public: // Initialiser for TCPConnection class. TCPConnection(SOCKET Connection, const char *IpAddress, Wrapper::Encryption &RSA) : - m_Encryption(RSA), m_Socket(Connection), m_IpAddress(IpAddress) { + m_Encryption(RSA), m_Socket(Connection), m_IpAddress(IpAddress) + { printf("[=>] %s connected!\n", IpAddress); } @@ -40,12 +43,14 @@ namespace Networking { ByteArray ReceiveBytes(); // Overload for getting the socket, in case we need to expose it. - SOCKET operator()() { + SOCKET operator()() + { return m_Socket; } // Expose the encryption key for the connection. - ByteArray GetEncryptionKey() { + ByteArray GetEncryptionKey() + { return m_Encryption.GetKey(); } }; @@ -53,7 +58,8 @@ namespace Networking { // Basic TCP server. Supports custom connection handling (pass a lambda to the handler list). using ConnectionHandler = std::function; - class TCPServer { + class TCPServer + { WSADATA m_WinSocks; SOCKET m_Socket; sockaddr_in m_Context; @@ -64,9 +70,10 @@ namespace Networking { public: // Default constructor, nothing needed for now. TCPServer() = default; - + // Handle destruction of server once it goes out of scope. - ~TCPServer() { + ~TCPServer() + { // If we have a socket, close it. if(m_Socket) closesocket(m_Socket); @@ -80,7 +87,8 @@ namespace Networking { void AcceptConnection(); // Overload for adding connection handlers, C# style support for events. - void operator+=(std::function Function) { + void operator+=(std::function Function) + { m_ConnectionHandler = Function; } }; -- cgit v1.2.3