Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
Connection Class Reference

#include <Connection.h>

Inherits MemoryPoolObject.

Public Member Functions

 Connection ()
 
void update ()
 
void init ()
 
void reset ()
 
UnsignedInt doSend ()
 
void doRecv ()
 
Bool allCommandsReady (UnsignedInt frame)
 
Bool isQueueEmpty ()
 
void attachTransport (Transport *transport)
 
void setUser (User *user)
 
UsergetUser ()
 
void setFrameGrouping (time_t frameGrouping)
 
void sendNetCommandMsg (NetCommandMsg *msg, UnsignedByte relay)
 
NetCommandRefprocessAck (NetAckBothCommandMsg *msg)
 
NetCommandRefprocessAck (NetAckStage1CommandMsg *msg)
 
NetCommandRefprocessAck (NetCommandMsg *msg)
 
NetCommandRefprocessAck (UnsignedShort commandID, UnsignedByte originalPlayerID)
 
void clearCommandsExceptFrom (Int playerIndex)
 
void setQuitting (void)
 
Bool isQuitting (void)
 
- Public Member Functions inherited from MemoryPoolObject
void deleteInstance ()
 

Protected Member Functions

void doRetryMetrics ()
 
- Protected Member Functions inherited from MemoryPoolObject
virtual ~MemoryPoolObject ()
 
void * operator new (size_t s)
 
void operator delete (void *p)
 
virtual MemoryPoolgetObjectMemoryPool ()=0
 

Protected Attributes

Bool m_isQuitting
 
UnsignedInt m_quitTime
 
Transportm_transport
 
Userm_user
 
NetCommandListm_netCommandList
 
time_t m_retryTime
 The time between sending retry packets for this connection. Time is in milliseconds.
 
Real m_averageLatency
 The average time between sending a command and receiving an ACK.
 
Real m_latencies [CONNECTION_LATENCY_HISTORY_LENGTH]
 List of the last 100 latencies.
 
time_t m_frameGrouping
 The minimum time between packet sends.
 
time_t m_lastTimeSent
 The time of the last packet send.
 
Int m_numRetries
 The number of retries for the last second.
 
time_t m_retryMetricsTime
 The start time of the current retry metrics thing.
 

Detailed Description

Definition at line 48 of file Connection.h.

Constructor & Destructor Documentation

◆ Connection()

Connection::Connection ( )

The constructor.

Definition at line 37 of file Connection.cpp.

Member Function Documentation

◆ allCommandsReady()

Bool Connection::allCommandsReady ( UnsignedInt frame)

◆ attachTransport()

void Connection::attachTransport ( Transport * transport)

Attach the transport object that this connection should use.

Definition at line 118 of file Connection.cpp.

◆ clearCommandsExceptFrom()

void Connection::clearCommandsExceptFrom ( Int playerIndex)

Definition at line 224 of file Connection.cpp.

◆ doRecv()

void Connection::doRecv ( )

◆ doRetryMetrics()

void Connection::doRetryMetrics ( )
protected

Definition at line 401 of file Connection.cpp.

◆ doSend()

UnsignedInt Connection::doSend ( )

This is the good part. We take all the network commands queued up for this connection, packetize them and put them on the transport's send queue for actual sending.

Todo
Make the act of giving the transport object a packet to send more efficient. Make the transport take a NetPacket object rather than the raw data, thus avoiding an extra memcpy.

Definition at line 262 of file Connection.cpp.

◆ getUser()

User * Connection::getUser ( )

Return the user object.

Definition at line 136 of file Connection.cpp.

◆ init()

void Connection::init ( )

Initialize the connection and any subsystems.

Definition at line 75 of file Connection.cpp.

◆ isQueueEmpty()

Bool Connection::isQueueEmpty ( )

Definition at line 244 of file Connection.cpp.

◆ isQuitting()

Bool Connection::isQuitting ( void )
inline

Definition at line 80 of file Connection.h.

◆ processAck() [1/4]

NetCommandRef * Connection::processAck ( NetAckBothCommandMsg * msg)

Definition at line 340 of file Connection.cpp.

◆ processAck() [2/4]

NetCommandRef * Connection::processAck ( NetAckStage1CommandMsg * msg)

Definition at line 336 of file Connection.cpp.

◆ processAck() [3/4]

NetCommandRef * Connection::processAck ( NetCommandMsg * msg)

Definition at line 344 of file Connection.cpp.

◆ processAck() [4/4]

NetCommandRef * Connection::processAck ( UnsignedShort commandID,
UnsignedByte originalPlayerID )

The person we are sending to has ack'd one of the messages we sent him. Take that message off the list of commands to send.

Definition at line 362 of file Connection.cpp.

◆ reset()

void Connection::reset ( )

Take the connection back to the initial state.

Definition at line 105 of file Connection.cpp.

◆ sendNetCommandMsg()

void Connection::sendNetCommandMsg ( NetCommandMsg * msg,
UnsignedByte relay )

Add this network command to the send queue for this connection. The relay is the mask specifying the people the person we are sending to should send to. The relay mostly has to do with the packet router.

Definition at line 145 of file Connection.cpp.

◆ setFrameGrouping()

void Connection::setFrameGrouping ( time_t frameGrouping)

Definition at line 396 of file Connection.cpp.

◆ setQuitting()

void Connection::setQuitting ( void )

Definition at line 251 of file Connection.cpp.

◆ setUser()

void Connection::setUser ( User * user)

Assign this connection a user. This is the user to whome we send all our packetized goodies.

Definition at line 125 of file Connection.cpp.

◆ update()

void Connection::update ( )

Doesn't really do anything.

Definition at line 112 of file Connection.cpp.

Member Data Documentation

◆ m_averageLatency

Real Connection::m_averageLatency
protected

The average time between sending a command and receiving an ACK.

Definition at line 97 of file Connection.h.

◆ m_frameGrouping

time_t Connection::m_frameGrouping
protected

The minimum time between packet sends.

Definition at line 100 of file Connection.h.

◆ m_isQuitting

Bool Connection::m_isQuitting
protected

Definition at line 89 of file Connection.h.

◆ m_lastTimeSent

time_t Connection::m_lastTimeSent
protected

The time of the last packet send.

Definition at line 101 of file Connection.h.

◆ m_latencies

Real Connection::m_latencies[CONNECTION_LATENCY_HISTORY_LENGTH]
protected

List of the last 100 latencies.

Definition at line 98 of file Connection.h.

◆ m_netCommandList

NetCommandList* Connection::m_netCommandList
protected

Definition at line 95 of file Connection.h.

◆ m_numRetries

Int Connection::m_numRetries
protected

The number of retries for the last second.

Definition at line 102 of file Connection.h.

◆ m_quitTime

UnsignedInt Connection::m_quitTime
protected

Definition at line 90 of file Connection.h.

◆ m_retryMetricsTime

time_t Connection::m_retryMetricsTime
protected

The start time of the current retry metrics thing.

Definition at line 103 of file Connection.h.

◆ m_retryTime

time_t Connection::m_retryTime
protected

The time between sending retry packets for this connection. Time is in milliseconds.

Definition at line 96 of file Connection.h.

◆ m_transport

Transport* Connection::m_transport
protected

Definition at line 92 of file Connection.h.

◆ m_user

User* Connection::m_user
protected

Definition at line 93 of file Connection.h.


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