Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CNetClientSession Class Reference

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

#include <NetSession.h>

Inheritance diagram for CNetClientSession:
Collaboration diagram for CNetClientSession:

Public Member Functions

 CNetClientSession (CNetClient &client)
 
 ~CNetClientSession ()
 
bool Connect (const CStr &server, const u16 port, ENetHost *enetClient)
 
void Shutdown ()
 Shut down the net session. More...
 
void ProcessPolledMessages ()
 Processes pending messages. More...
 
virtual bool SendMessage (const CNetMessage *message) override
 Queue up a message to send to the server on the next Loop() call. More...
 
u32 GetLastReceivedTime () const
 Number of milliseconds since the most recent packet of the server was received. More...
 
u32 GetMeanRTT () const
 Average round trip time to the server. More...
 
CNetFileTransfererGetFileTransferer ()
 
- Public Member Functions inherited from INetSession
virtual ~INetSession ()
 
virtual bool SendMessage (const CNetMessage *message)=0
 

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

CNetClientm_Client
 
CNetFileTransferer m_FileTransferer
 
boost::lockfree::queue< ENetEvent > m_IncomingMessages
 
boost::lockfree::queue< ENetPacket * > m_OutgoingMessages
 
bool m_Connected = false
 
std::atomic< u32m_LastReceivedTime
 
std::atomic< u32m_MeanRTT
 
std::atomic< bool > m_LoopRunning
 
std::atomic< bool > m_ShouldShutdown
 
ENetHostm_Host
 
ENetPeerm_Server
 
CNetStatsTablem_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 u16  port,
ENetHost enetClient 
)

◆ Flush()

void CNetClientSession::Flush ( )
private

Flush queued outgoing network messages.

◆ GetFileTransferer()

CNetFileTransferer & CNetClientSession::GetFileTransferer ( )
inline

◆ GetLastReceivedTime()

u32 CNetClientSession::GetLastReceivedTime ( ) const

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

◆ GetMeanRTT()

u32 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)
overridevirtual

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

Implements INetSession.

◆ 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

ENetHost* CNetClientSession::m_Host
private

◆ m_IncomingMessages

boost::lockfree::queue<ENetEvent> CNetClientSession::m_IncomingMessages
private

◆ m_LastReceivedTime

std::atomic<u32> CNetClientSession::m_LastReceivedTime
private

◆ m_LoopRunning

std::atomic<bool> CNetClientSession::m_LoopRunning
private

◆ m_MeanRTT

std::atomic<u32> CNetClientSession::m_MeanRTT
private

◆ m_OutgoingMessages

boost::lockfree::queue<ENetPacket*> CNetClientSession::m_OutgoingMessages
private

◆ m_Server

ENetPeer* CNetClientSession::m_Server
private

◆ m_ShouldShutdown

std::atomic<bool> CNetClientSession::m_ShouldShutdown
private

◆ m_Stats

CNetStatsTable* CNetClientSession::m_Stats
private

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