27#include <boost/lockfree/queue.hpp>
struct _ENetHost ENetHost
Definition: NetClient.h:37
Various declarations shared by networking code.
struct _ENetPeer ENetPeer
Definition: NetHost.h:30
NetDisconnectReason
Reasons sent by server to clients in disconnection messages.
Definition: NetHost.h:63
constexpr u32 NETWORK_WARNING_TIMEOUT
Report the peer if we didn't receive a packet after this time (milliseconds).
Definition: NetSession.h:34
Manages states, events, actions and transitions between states.
Definition: FSM.h:68
The client end of a network session.
Definition: NetSession.h:68
u32 GetMeanRTT() const
Average round trip time to the server.
Definition: NetSession.cpp:225
bool m_Connected
Definition: NetSession.h:130
static void RunNetLoop(CNetClientSession *session)
The client NetSession is threaded to avoid getting timeouts if the main thread hangs.
Definition: NetSession.cpp:91
NONCOPYABLE(CNetClientSession)
std::atomic< bool > m_LoopRunning
Definition: NetSession.h:137
boost::lockfree::queue< ENetPacket * > m_OutgoingMessages
Definition: NetSession.h:127
ENetPeer * m_Server
Definition: NetSession.h:141
void ProcessPolledMessages()
Processes pending messages.
Definition: NetSession.cpp:171
std::atomic< u32 > m_MeanRTT
Definition: NetSession.h:134
u32 GetLastReceivedTime() const
Number of milliseconds since the most recent packet of the server was received.
Definition: NetSession.cpp:217
CNetClient & m_Client
Definition: NetSession.h:120
virtual bool SendMessage(const CNetMessage *message) override
Queue up a message to send to the server on the next Loop() call.
Definition: NetSession.cpp:199
std::atomic< u32 > m_LastReceivedTime
Definition: NetSession.h:133
void Poll()
Process queued incoming messages.
Definition: NetSession.cpp:121
CNetFileTransferer m_FileTransferer
Definition: NetSession.h:122
bool Connect(const CStr &server, const u16 port, ENetHost *enetClient)
Definition: NetSession.cpp:58
~CNetClientSession()
Definition: NetSession.cpp:41
CNetStatsTable * m_Stats
Definition: NetSession.h:142
void Flush()
Flush queued outgoing network messages.
Definition: NetSession.cpp:155
void Shutdown()
Shut down the net session.
Definition: NetSession.cpp:116
std::atomic< bool > m_ShouldShutdown
Definition: NetSession.h:138
ENetHost * m_Host
Definition: NetSession.h:140
CNetClientSession(CNetClient &client)
Definition: NetSession.cpp:34
CNetFileTransferer & GetFileTransferer()
Definition: NetSession.h:108
boost::lockfree::queue< ENetEvent > m_IncomingMessages
Definition: NetSession.h:125
Network client.
Definition: NetClient.h:60
Handles transferring files between clients and servers.
Definition: NetFileTransfer.h:49
The base class for all network messages exchanged within the game.
Definition: NetMessage.h:33
The server's end of a network session.
Definition: NetSession.h:155
void DisconnectNow(NetDisconnectReason reason)
Sends an unreliable disconnection notification to the client.
Definition: NetSession.cpp:269
CNetServerSession(CNetServerWorker &server, ENetPeer *peer)
Definition: NetSession.cpp:233
u32 GetMeanRTT() const
Average round trip time to the client.
Definition: NetSession.cpp:251
CStr m_GUID
Definition: NetSession.h:213
void Disconnect(NetDisconnectReason reason)
Sends a disconnection notification to the client, and sends a NMT_CONNECTION_LOST message to the sess...
Definition: NetSession.cpp:259
CStrW m_UserName
Definition: NetSession.h:214
virtual bool SendMessage(const CNetMessage *message)
Send a message to the client.
Definition: NetSession.cpp:277
u32 GetIPAddress() const
Definition: NetSession.cpp:238
ENetPeer * m_Peer
Definition: NetSession.h:211
const CStrW & GetUserName() const
Definition: NetSession.h:166
CStr m_Password
Definition: NetSession.h:216
void SetHostID(u32 id)
Definition: NetSession.h:170
CNetFileTransferer m_FileTransferer
Definition: NetSession.h:209
CNetFileTransferer & GetFileTransferer()
Definition: NetSession.h:204
void SetUserName(const CStrW &name)
Definition: NetSession.h:167
const CStr & GetGUID() const
Definition: NetSession.h:163
u32 GetLastReceivedTime() const
Number of milliseconds since the latest packet of that client was received.
Definition: NetSession.cpp:243
u32 m_HostID
Definition: NetSession.h:215
void SetGUID(const CStr &guid)
Definition: NetSession.h:164
CNetServerWorker & GetServer()
Definition: NetSession.h:161
NONCOPYABLE(CNetServerSession)
CNetServerWorker & m_Server
Definition: NetSession.h:207
u32 GetHostID() const
Definition: NetSession.h:169
Network server worker thread.
Definition: NetServer.h:213
ENet connection statistics profiler table.
Definition: NetStats.h:39
Interface for sessions to which messages can be sent.
Definition: NetSession.h:56
virtual bool SendMessage(const CNetMessage *message)=0
virtual ~INetSession()
Definition: NetSession.h:58
uint16_t u16
Definition: types.h:38
uint32_t u32
Definition: types.h:39