Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetClient.h
/* Copyright (C) 2020 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||||||||||
Stan: Year needs rebase propably? | |||||||||||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||||||||||
* | * | ||||||||||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||||||||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||||||||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||||||||||
* (at your option) any later version. | * (at your option) any later version. | ||||||||||||
* | * | ||||||||||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||||||||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | public: | ||||||||||||
/** | /** | ||||||||||||
* Returns the GUID of the local client. | * Returns the GUID of the local client. | ||||||||||||
* Used for distinguishing observers. | * Used for distinguishing observers. | ||||||||||||
*/ | */ | ||||||||||||
CStr GetGUID() const { return m_GUID; } | CStr GetGUID() const { return m_GUID; } | ||||||||||||
/** | /** | ||||||||||||
* Set connection data to the remote networked server. | |||||||||||||
* @param address IP address or host name to connect to | |||||||||||||
*/ | |||||||||||||
void SetupServerData(CStr address, u16 port, bool stun); | |||||||||||||
/** | |||||||||||||
* Set up a connection to the remote networked server. | * Set up a connection to the remote networked server. | ||||||||||||
* @param server IP address or host name to connect to | * Must call SetupServerData first. | ||||||||||||
* @return true on success, false on connection failure | |||||||||||||
*/ | |||||||||||||
bool SetupConnection(ENetHost* enetClient); | |||||||||||||
StanUnsubmitted Not Done Inline ActionsNot sure where EnetHost is pulled but you might be missing and include Stan: Not sure where EnetHost is pulled but you might be missing and include | |||||||||||||
SilierAuthorUnsubmitted Done Inline Actionsit is wroking in svn Silier: it is wroking in svn | |||||||||||||
StanUnsubmitted Not Done Inline ActionsDid you try no pch? Stan: Did you try no pch? | |||||||||||||
wraitiiUnsubmitted Not Done Inline ActionsThe point is that this was already there, so it can't possibly break svn. wraitii: The point is that this was already there, so it can't possibly break svn.
Regardless, it is… | |||||||||||||
/** | |||||||||||||
* Connect to the remote networked server using lobby. | |||||||||||||
* Push netstatus messages on failure. | |||||||||||||
* @return true on success, false on connection failure | * @return true on success, false on connection failure | ||||||||||||
Done Inline Actions
wraitii: | |||||||||||||
*/ | */ | ||||||||||||
bool SetupConnection(const CStr& server, const u16 port, ENetHost* enetClient); | bool TryToConnect(const CStr& hostJID); | ||||||||||||
/** | /** | ||||||||||||
* Destroy the connection to the server. | * Destroy the connection to the server. | ||||||||||||
* This client probably cannot be used again. | * This client probably cannot be used again. | ||||||||||||
Not Done Inline ActionsAs written elsewhere, I think SetupConnection needs to be removed from the public interface now that TryToConnect exists. Add documentation to these functions too. If you keep SetupConnection, move it below the other two so it reflects call order. wraitii: As written elsewhere, I think SetupConnection needs to be removed from the public interface now… | |||||||||||||
Done Inline Actionscant, JSI_Network::StartNetworkHost needs it and using try to connect is overkill even if doable Silier: cant, JSI_Network::StartNetworkHost needs it and using try to connect is overkill even if doable | |||||||||||||
Not Done Inline ActionsAH you're right. Still, I'd move it below + doc. wraitii: AH you're right. Still, I'd move it below + doc. | |||||||||||||
Done Inline Actionshmm, maybe it is actually doable anyway Silier: hmm, maybe it is actually doable anyway | |||||||||||||
*/ | */ | ||||||||||||
void DestroyConnection(); | void DestroyConnection(); | ||||||||||||
/** | /** | ||||||||||||
* Poll the connection for messages from the server and process them, and send | * Poll the connection for messages from the server and process them, and send | ||||||||||||
* any queued messages. | * any queued messages. | ||||||||||||
* This must be called frequently (i.e. once per frame). | * This must be called frequently (i.e. once per frame). | ||||||||||||
*/ | */ | ||||||||||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | public: | ||||||||||||
* Call when the client has paused or unpaused the game. | * Call when the client has paused or unpaused the game. | ||||||||||||
*/ | */ | ||||||||||||
void SendPausedMessage(bool pause); | void SendPausedMessage(bool pause); | ||||||||||||
/** | /** | ||||||||||||
* @return Whether the NetClient is shutting down. | * @return Whether the NetClient is shutting down. | ||||||||||||
*/ | */ | ||||||||||||
bool ShouldShutdown() const; | bool ShouldShutdown() const; | ||||||||||||
/** | |||||||||||||
Not Done Inline ActionsDoc wraitii: Doc | |||||||||||||
* Call in case of getting connection data from server hosting match failed to inform js. | |||||||||||||
*/ | |||||||||||||
wraitiiUnsubmitted Not Done Inline Actions
(suggestion) wraitii: (suggestion) | |||||||||||||
void HandleGetServerDataFailed(const CStr& error); | |||||||||||||
private: | private: | ||||||||||||
void SendAuthenticateMessage(); | void SendAuthenticateMessage(); | ||||||||||||
// Net message / FSM transition handlers | // Net message / FSM transition handlers | ||||||||||||
static bool OnConnect(void* context, CFsmEvent* event); | static bool OnConnect(void* context, CFsmEvent* event); | ||||||||||||
static bool OnHandshake(void* context, CFsmEvent* event); | static bool OnHandshake(void* context, CFsmEvent* event); | ||||||||||||
static bool OnHandshakeResponse(void* context, CFsmEvent* event); | static bool OnHandshakeResponse(void* context, CFsmEvent* event); | ||||||||||||
Show All 23 Lines | private: | ||||||||||||
/** | /** | ||||||||||||
* Push a message onto the GUI queue listing the current player assignments. | * Push a message onto the GUI queue listing the current player assignments. | ||||||||||||
*/ | */ | ||||||||||||
void PostPlayerAssignmentsToScript(); | void PostPlayerAssignmentsToScript(); | ||||||||||||
CGame *m_Game; | CGame *m_Game; | ||||||||||||
CStrW m_UserName; | CStrW m_UserName; | ||||||||||||
CStr m_HostingPlayerName; | CStr m_HostingPlayerName; | ||||||||||||
CStr m_ServerAddress; | |||||||||||||
u16 m_ServerPort; | |||||||||||||
bool m_UseSTUN; | |||||||||||||
/// Current network session (or NULL if not connected) | /// Current network session (or NULL if not connected) | ||||||||||||
CNetClientSession* m_Session; | CNetClientSession* m_Session; | ||||||||||||
std::thread m_PollingThread; | std::thread m_PollingThread; | ||||||||||||
/// Turn manager associated with the current game (or NULL if we haven't started the game yet) | /// Turn manager associated with the current game (or NULL if we haven't started the game yet) | ||||||||||||
CNetClientTurnManager* m_ClientTurnManager; | CNetClientTurnManager* m_ClientTurnManager; | ||||||||||||
Show All 33 Lines |
Wildfire Games · Phabricator
Year needs rebase propably?