Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetSession.h
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
class CNetClientSession : public INetSession | class CNetClientSession : public INetSession | ||||
{ | { | ||||
NONCOPYABLE(CNetClientSession); | NONCOPYABLE(CNetClientSession); | ||||
public: | public: | ||||
CNetClientSession(CNetClient& client); | CNetClientSession(CNetClient& client); | ||||
~CNetClientSession(); | ~CNetClientSession(); | ||||
bool Connect(const CStr& server, const u16 port, const bool isLocalClient, ENetHost* enetClient); | bool Connect(const CStr& server, const u16 port, ENetHost* enetClient); | ||||
/** | /** | ||||
* Process queued incoming messages. | * Process queued incoming messages. | ||||
*/ | */ | ||||
void Poll(); | void Poll(); | ||||
/** | /** | ||||
* Flush queued outgoing network messages. | * Flush queued outgoing network messages. | ||||
Show All 32 Lines | |||||
private: | private: | ||||
CNetClient& m_Client; | CNetClient& m_Client; | ||||
CNetFileTransferer m_FileTransferer; | CNetFileTransferer m_FileTransferer; | ||||
ENetHost* m_Host; | ENetHost* m_Host; | ||||
ENetPeer* m_Server; | ENetPeer* m_Server; | ||||
CNetStatsTable* m_Stats; | CNetStatsTable* m_Stats; | ||||
bool m_IsLocalClient; | |||||
}; | }; | ||||
/** | /** | ||||
* The server's end of a network session. | * The server's end of a network session. | ||||
* Represents an abstraction of the state of the client, storing all the per-client data | * Represents an abstraction of the state of the client, storing all the per-client data | ||||
* needed by the server. | * needed by the server. | ||||
* | * | ||||
Show All 16 Lines | public: | ||||
void SetUserName(const CStrW& name) { m_UserName = name; } | void SetUserName(const CStrW& name) { m_UserName = name; } | ||||
u32 GetHostID() const { return m_HostID; } | u32 GetHostID() const { return m_HostID; } | ||||
void SetHostID(u32 id) { m_HostID = id; } | void SetHostID(u32 id) { m_HostID = id; } | ||||
u32 GetIPAddress() const; | u32 GetIPAddress() const; | ||||
/** | /** | ||||
* Whether this client is running in the same process as the server. | |||||
*/ | |||||
bool IsLocalClient() const; | |||||
/** | |||||
* Number of milliseconds since the latest packet of that client was received. | * Number of milliseconds since the latest packet of that client was received. | ||||
*/ | */ | ||||
u32 GetLastReceivedTime() const; | u32 GetLastReceivedTime() const; | ||||
/** | /** | ||||
* Average round trip time to the client. | * Average round trip time to the client. | ||||
*/ | */ | ||||
u32 GetMeanRTT() const; | u32 GetMeanRTT() const; | ||||
Show All 9 Lines | public: | ||||
/** | /** | ||||
* Sends an unreliable disconnection notification to the client. | * Sends an unreliable disconnection notification to the client. | ||||
* The server will not receive any disconnection notification. | * The server will not receive any disconnection notification. | ||||
* The server will not receive any further messages sent via this session. | * The server will not receive any further messages sent via this session. | ||||
*/ | */ | ||||
void DisconnectNow(NetDisconnectReason reason); | void DisconnectNow(NetDisconnectReason reason); | ||||
/** | /** | ||||
* Prevent timeouts for the client running in the same process as the server. | |||||
*/ | |||||
void SetLocalClient(bool isLocalClient); | |||||
/** | |||||
* Allows increasing the timeout to prevent drops during an expensive operation, | * Allows increasing the timeout to prevent drops during an expensive operation, | ||||
* and decreasing it back to normal afterwards. | * and decreasing it back to normal afterwards. | ||||
*/ | */ | ||||
void SetLongTimeout(bool longTimeout); | void SetLongTimeout(bool longTimeout); | ||||
/** | /** | ||||
* Send a message to the client. | * Send a message to the client. | ||||
*/ | */ | ||||
virtual bool SendMessage(const CNetMessage* message); | virtual bool SendMessage(const CNetMessage* message); | ||||
CNetFileTransferer& GetFileTransferer() { return m_FileTransferer; } | CNetFileTransferer& GetFileTransferer() { return m_FileTransferer; } | ||||
private: | private: | ||||
CNetServerWorker& m_Server; | CNetServerWorker& m_Server; | ||||
CNetFileTransferer m_FileTransferer; | CNetFileTransferer m_FileTransferer; | ||||
ENetPeer* m_Peer; | ENetPeer* m_Peer; | ||||
CStr m_GUID; | CStr m_GUID; | ||||
CStrW m_UserName; | CStrW m_UserName; | ||||
u32 m_HostID; | u32 m_HostID; | ||||
bool m_IsLocalClient; | |||||
}; | }; | ||||
#endif // NETSESSION_H | #endif // NETSESSION_H |
Wildfire Games · Phabricator