Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CNetClientSession Class Reference

The client end of a network session. More...

#include <NetClientSession.h>

Collaboration diagram for CNetClientSession:

Public Member Functions

 CNetClientSession (CNetClient &client)
 
 ~CNetClientSession ()
 
bool Connect (const CStr &server, const std::uint16_t port, ENetHost *enetClient)
 
void Shutdown ()
 Shut down the net session. More...
 
void ProcessPolledMessages ()
 Processes pending messages. More...
 
bool SendMessage (const CNetMessage *message)
 Queue up a message to send to the server on the next Loop() call. More...
 
std::uint32_t GetLastReceivedTime () const
 Number of milliseconds since the most recent packet of the server was received. More...
 
std::uint32_t GetMeanRTT () const
 Average round trip time to the server. More...
 
CNetFileTransferer & GetFileTransferer ()
 

Static Public Member Functions

static void RunNetLoop (CNetClientSession *session)
 The client NetSession is threaded to avoid getting timeouts if the main thread hangs. More...
 

Private Member Functions

 NONCOPYABLE (CNetClientSession)
 
void Poll ()
 Process queued incoming messages. More...
 
void Flush ()
 Flush queued outgoing network messages. More...
 

Private Attributes

CNetClient & m_Client
 
CNetFileTransferer m_FileTransferer
 
boost::lockfree::queue< ENetEvent > m_IncomingMessages {16}
 
boost::lockfree::queue< ENetPacket * > m_OutgoingMessages {16}
 
bool m_Connected {false}
 
bool m_WasConnected {false}
 
std::atomic< std::uint32_t > m_LastReceivedTime {0}
 
std::atomic< std::uint32_t > m_MeanRTT {0}
 
std::atomic< bool > m_LoopRunning {false}
 
std::atomic< bool > m_ShouldShutdown {false}
 
std::unique_ptr< ENetHost, DestroyHost > m_Host
 
std::unique_ptr< ENetPeer, DestroyPeer > m_Server
 
std::unique_ptr< CNetStatsTable > m_Stats
 

Detailed Description

The client end of a network session.

Provides an abstraction of the network interface, allowing communication with the server. The NetClientSession is threaded, so all calls to the public interface must be thread-safe.

Constructor & Destructor Documentation

◆ CNetClientSession()

CNetClientSession::CNetClientSession ( CNetClient &  client)

◆ ~CNetClientSession()

CNetClientSession::~CNetClientSession ( )

Member Function Documentation

◆ Connect()

bool CNetClientSession::Connect ( const CStr &  server,
const std::uint16_t  port,
ENetHost *  enetClient 
)

◆ Flush()

void CNetClientSession::Flush ( )
private

Flush queued outgoing network messages.

◆ GetFileTransferer()

CNetFileTransferer & CNetClientSession::GetFileTransferer ( )
inline

◆ GetLastReceivedTime()

std::uint32_t CNetClientSession::GetLastReceivedTime ( ) const

Number of milliseconds since the most recent packet of the server was received.

◆ GetMeanRTT()

std::uint32_t CNetClientSession::GetMeanRTT ( ) const

Average round trip time to the server.

◆ NONCOPYABLE()

CNetClientSession::NONCOPYABLE ( CNetClientSession  )
private

◆ Poll()

void CNetClientSession::Poll ( )
private

Process queued incoming messages.

◆ ProcessPolledMessages()

void CNetClientSession::ProcessPolledMessages ( )

Processes pending messages.

◆ RunNetLoop()

void CNetClientSession::RunNetLoop ( CNetClientSession *  session)
static

The client NetSession is threaded to avoid getting timeouts if the main thread hangs.

Call Connect() before starting this loop.

◆ SendMessage()

bool CNetClientSession::SendMessage ( const CNetMessage *  message)

Queue up a message to send to the server on the next Loop() call.

◆ Shutdown()

void CNetClientSession::Shutdown ( )

Shut down the net session.

Member Data Documentation

◆ m_Client

CNetClient& CNetClientSession::m_Client
private

◆ m_Connected

bool CNetClientSession::m_Connected {false}
private

◆ m_FileTransferer

CNetFileTransferer CNetClientSession::m_FileTransferer
private

◆ m_Host

std::unique_ptr<ENetHost, DestroyHost> CNetClientSession::m_Host
private

◆ m_IncomingMessages

boost::lockfree::queue<ENetEvent> CNetClientSession::m_IncomingMessages {16}
private

◆ m_LastReceivedTime

std::atomic<std::uint32_t> CNetClientSession::m_LastReceivedTime {0}
private

◆ m_LoopRunning

std::atomic<bool> CNetClientSession::m_LoopRunning {false}
private

◆ m_MeanRTT

std::atomic<std::uint32_t> CNetClientSession::m_MeanRTT {0}
private

◆ m_OutgoingMessages

boost::lockfree::queue<ENetPacket*> CNetClientSession::m_OutgoingMessages {16}
private

◆ m_Server

std::unique_ptr<ENetPeer, DestroyPeer> CNetClientSession::m_Server
private

◆ m_ShouldShutdown

std::atomic<bool> CNetClientSession::m_ShouldShutdown {false}
private

◆ m_Stats

std::unique_ptr<CNetStatsTable> CNetClientSession::m_Stats
private

◆ m_WasConnected

bool CNetClientSession::m_WasConnected {false}
private

The documentation for this class was generated from the following files: