aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/socketcreator.h
diff options
context:
space:
mode:
authorAmos <48657826+Mauler125@users.noreply.github.com>2022-03-04 00:54:01 +0100
committerAmos <48657826+Mauler125@users.noreply.github.com>2022-03-04 00:54:01 +0100
commitbc7375807af20ad9bb07efa14ed538fce2f9ea00 (patch)
treef78cfa2738ff40ed4473454c34e8b71632c4253c /NorthstarDedicatedTest/socketcreator.h
parentf108edc345d9709dbdc977578bf851b4b3aa0939 (diff)
downloadNorthstarLauncher-bc7375807af20ad9bb07efa14ed538fce2f9ea00.tar.gz
NorthstarLauncher-bc7375807af20ad9bb07efa14ed538fce2f9ea00.zip
RCON implementation
* Full CNetAdr rewrite (protocol agnostic) * Full CSocketCreator class rebuild (based on Valve's implementation) * RCON implementation on server and client * Misc cleanup
Diffstat (limited to 'NorthstarDedicatedTest/socketcreator.h')
-rw-r--r--NorthstarDedicatedTest/socketcreator.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/socketcreator.h b/NorthstarDedicatedTest/socketcreator.h
new file mode 100644
index 00000000..9a4453af
--- /dev/null
+++ b/NorthstarDedicatedTest/socketcreator.h
@@ -0,0 +1,58 @@
+#pragma once
+#include "NetAdr2.h"
+#include "igameserverdata.h"
+
+//-----------------------------------------------------------------------------
+// Purpose: container class to handle network streams
+//-----------------------------------------------------------------------------
+class CSocketCreator
+{
+public:
+ CSocketCreator(void);
+ ~CSocketCreator(void);
+
+ void RunFrame(void);
+ void ProcessAccept(void);
+
+ bool ConfigureListenSocket(int iSocket);
+ bool ConfigureConnectSocket(SocketHandle_t hSocket);
+
+ bool CreateListenSocket(const CNetAdr2& netAdr2, bool bListenOnAllInterfaces);
+ void CloseListenSocket(void);
+
+ int ConnectSocket(const CNetAdr2& netAdr2, bool bSingleSocket);
+ void DisconnectSocket(void);
+
+ int OnSocketAccepted(SocketHandle_t hSocket, CNetAdr2 netAdr2);
+
+ void CloseAcceptedSocket(int nIndex);
+ void CloseAllAcceptedSockets(void);
+
+ bool IsListening(void) const;
+ bool IsSocketBlocking(void) const;
+
+ int GetAcceptedSocketCount(void) const;
+ SocketHandle_t GetAcceptedSocketHandle(int nIndex) const;
+ const CNetAdr2& GetAcceptedSocketAddress(int nIndex) const;
+ CConnectedNetConsoleData* GetAcceptedSocketData(int nIndex) const;
+
+public:
+ struct AcceptedSocket_t
+ {
+ SocketHandle_t m_hSocket{};
+ CNetAdr2 m_Address{};
+ CConnectedNetConsoleData* m_pData = nullptr;
+
+ bool operator==(const AcceptedSocket_t& rhs) const { return (m_Address.CompareAdr(rhs.m_Address, false) == 0); }
+ };
+
+ std::vector<AcceptedSocket_t> m_hAcceptedSockets{};
+ SocketHandle_t m_hListenSocket {}; // Used to accept connections.
+ CNetAdr2 m_ListenAddress {}; // Address used to listen on.
+
+private:
+ enum
+ {
+ SOCKET_TCP_MAX_ACCEPTS = 2
+ };
+};