Launch session at construction of Net*

This way it's statically assured that the session aren't launched
multiple times.
This commit is contained in:
phosit
2026-03-03 19:46:40 +01:00
parent 314e2a58cf
commit bc17e212bb
6 changed files with 86 additions and 129 deletions
+10 -6
View File
@@ -100,12 +100,6 @@ public:
*/
CStr GetGUID() const { return m_GUID; }
/**
* Set up a connection to the remote networked server.
* @return true on success, false on connection failure
*/
bool SetupConnection(ENetHost* enetClient);
/**
* Connect to the remote networked server using lobby.
* Push netstatus messages on failure.
@@ -259,6 +253,10 @@ public:
*/
void HandleGetServerDataFailed(const CStr& error);
private:
struct PrivateTag {};
CNetClient(PrivateTag, CGame* game, std::string serverAddressOrHostname,
std::uint16_t serverPont, const CStrW& username = L"anonymous", const CStr& hostJID = {},
std::string hashedPassword = {}, std::string controllerSecret = {});
void SendAuthenticateMessage();
@@ -286,6 +284,12 @@ private:
static bool OnClientPaused(CNetClient* client, CFsmEvent<CNetMessage*>* event);
static bool OnLoadedGame(CNetClient* client, CFsmEvent<CNetMessage*>* event);
/**
* Set up a connection to the remote networked server.
* @return true on success, false on connection failure
*/
void SetupConnection(ENetHost* enetClient);
/**
* Take ownership of a session object, and use it for all network communication.
*/