PGE API 0.4
PR00F's Game Engine full documentation
Loading...
Searching...
No Matches
pge_network::PgeServerStub Class Reference

The primary interface to stubbed server networking functionality. More...

Detailed Description

The primary interface to stubbed server networking functionality.

With current implementation is it more like a spy, but anyway I still call it stub.

Regarding the packet sender functions: we have 1 virtual client connected, so that:

Definition at line 30 of file PgeServerStub.h.

#include <PgeServerStub.h>

+ Inheritance diagram for pge_network::PgeServerStub:

Public Member Functions

 PgeServerStub (PGEcfgProfiles &cfgProfiles)
 
 PgeServerStub (const PgeServerStub &)=delete
 
PgeServerStuboperator= (const PgeServerStub &)=delete
 
 PgeServerStub (PgeServerStub &&)=delete
 
PgeServerStub && operator= (PgeServerStub &&)=delete
 
virtual ~PgeServerStub ()
 
bool initialize () override
 Initialize the network instance.
 
bool shutdown () override
 This stops the network instance.
 
bool isInitialized () const override
 Gets the state of the network instance.
 
void disconnect (const std::string &) override
 Terminates the active connection of the network instance.
 
void Update () override
 
bool pollIncomingMessages () override
 Moves incoming packets from the underlying network layer to PGE network layer as PgePackets.
 
void pollConnectionStateChanges () override
 
std::size_t getPacketQueueSize () const override
 
pge_network::PgePacket popFrontPacket () noexcept(false) override
 
std::set< pge_network::PgePktId > & getAllowListedPgeMessages () override
 
std::set< pge_network::MsgApp::TMsgId > & getAllowListedAppMessages () override
 
void send (const pge_network::PgePacket &pkt, const pge_network::PgeNetworkConnectionHandle &connHandle=pge_network::ServerConnHandle) override
 Sends the given packet to the network instance specified.
 
uint32_t getRxPacketCount () const override
 
uint32_t getTxPacketCount () const override
 
uint32_t getInjectPacketCount () const override
 
uint32_t getRxPacketPerSecondCount () const override
 
uint32_t getTxPacketPerSecondCount () const override
 
uint32_t getInjectPacketPerSecondCount () const override
 
const std::map< pge_network::MsgApp::TMsgId, uint32_t > & getRxMsgCount () const override
 
const std::map< pge_network::MsgApp::TMsgId, uint32_t > & getTxMsgCount () const override
 
const std::map< pge_network::MsgApp::TMsgId, uint32_t > & getInjectMsgCount () const override
 
std::map< pge_network::MsgApp::TMsgId, std::string > & getMsgAppId2StringMap () override
 
uint32_t getRxByteCount () const override
 
uint32_t getTxByteCount () const override
 
uint32_t getInjectByteCount () const override
 
void WriteList () const override
 Writes statistics to console.
 
bool startListening (const std::string &) override
 Starts listening to incoming PgeClient connections.
 
void sendToAllClientsExcept (const pge_network::PgePacket &pkt, const pge_network::PgeNetworkConnectionHandle &exceptConnHandle=0) override
 Sends the given packet to all client instances except the optionally specified client.
 
void sendToAll (const pge_network::PgePacket &pkt) override
 Sends the given packet to all known network instances, including the server itself (self).
 
void setDebugNickname (const pge_network::PgeNetworkConnectionHandle &, const std::string &) override
 Sets a debug helper name associated to the given connection handle.
 
int getPing (const pge_network::PgeNetworkConnectionHandle &, bool) override
 
float getQualityLocal (const pge_network::PgeNetworkConnectionHandle &, bool) override
 
float getQualityRemote (const pge_network::PgeNetworkConnectionHandle &, bool) override
 
float getRxByteRate (const pge_network::PgeNetworkConnectionHandle &, bool) override
 
float getTxByteRate (const pge_network::PgeNetworkConnectionHandle &, bool) override
 
int64_t getPendingUnreliableBytes (const pge_network::PgeNetworkConnectionHandle &, bool) override
 
int64_t getPendingReliableBytes (const pge_network::PgeNetworkConnectionHandle &, bool) override
 
int64_t getSentButUnAckedReliableBytes (const pge_network::PgeNetworkConnectionHandle &, bool) override
 
int64_t getInternalQueueTimeUSecs (const pge_network::PgeNetworkConnectionHandle &, bool) override
 
std::string getDetailedConnectionStatus (const pge_network::PgeNetworkConnectionHandle &) const override
 
- Public Member Functions inherited from pge_network::PgeIServer
- Public Member Functions inherited from pge_network::PgeIServerClient

Private Attributes

PGEcfgProfilesm_cfgProfiles
 
bool m_bInited {false}
 
uint32_t m_nPktCountTx { 0 }
 
std::map< pge_network::MsgApp::TMsgId, uint32_t > m_mapTxMsgCount
 

Additional Inherited Members

- Static Public Member Functions inherited from pge_network::PgeIServer
static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 

Constructor & Destructor Documentation

◆ PgeServerStub() [1/3]

pge_network::PgeServerStub::PgeServerStub ( PGEcfgProfiles & cfgProfiles)
inline

Definition at line 38 of file PgeServerStub.h.

◆ PgeServerStub() [2/3]

pge_network::PgeServerStub::PgeServerStub ( const PgeServerStub & )
delete

◆ PgeServerStub() [3/3]

pge_network::PgeServerStub::PgeServerStub ( PgeServerStub && )
delete

◆ ~PgeServerStub()

virtual pge_network::PgeServerStub::~PgeServerStub ( )
inlinevirtual

Definition at line 49 of file PgeServerStub.h.

Member Function Documentation

◆ disconnect()

void pge_network::PgeServerStub::disconnect ( const std::string & sExtraDebugText)
inlineoverridevirtual

Terminates the active connection of the network instance.

In case of server instance, this terminates the active connections of the server instance and stops listening. It also sends as many MsgUserDisconnectedFromServer to all clients as the number of clients, so all clients will be notified about all other clients disconnecting. A MsgUserDisconnectedFromServer will be injected into the message queue with the server's connection handle, so at application level the handleUserDisconnected() is expected to be invoked with connHandleServerSide = pge_network::ServerConnHandle.

In case of client instance, this disconnects the client from the server. If client was connected at time of calling this function, a MsgUserDisconnectedFromServer will be injected into the message queue with the server's connection handle, so at application level the handleUserDisconnected() is expected to be invoked with connHandleServerSide = pge_network::ServerConnHandle, for which the client is expected to remove all other players as well since they are/were also connecting to the same server and not available anymore from this client's perspective.

Parameters
sExtraDebugTextAn optional text that will be sent to the other side and will be logged to help debugging.

Implements pge_network::PgeIServerClient.

Definition at line 78 of file PgeServerStub.h.

◆ getAllowListedAppMessages()

std::set< pge_network::MsgApp::TMsgId > & pge_network::PgeServerStub::getAllowListedAppMessages ( )
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 108 of file PgeServerStub.h.

◆ getAllowListedPgeMessages()

std::set< pge_network::PgePktId > & pge_network::PgeServerStub::getAllowListedPgeMessages ( )
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 103 of file PgeServerStub.h.

◆ getDetailedConnectionStatus()

std::string pge_network::PgeServerStub::getDetailedConnectionStatus ( const pge_network::PgeNetworkConnectionHandle & ) const
inlineoverridevirtual

Implements pge_network::PgeIServer.

Definition at line 250 of file PgeServerStub.h.

◆ getInjectByteCount()

uint32_t pge_network::PgeServerStub::getInjectByteCount ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 149 of file PgeServerStub.h.

◆ getInjectMsgCount()

const std::map< pge_network::MsgApp::TMsgId, uint32_t > & pge_network::PgeServerStub::getInjectMsgCount ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 143 of file PgeServerStub.h.

◆ getInjectPacketCount()

uint32_t pge_network::PgeServerStub::getInjectPacketCount ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 135 of file PgeServerStub.h.

◆ getInjectPacketPerSecondCount()

uint32_t pge_network::PgeServerStub::getInjectPacketPerSecondCount ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 139 of file PgeServerStub.h.

◆ getInternalQueueTimeUSecs()

int64_t pge_network::PgeServerStub::getInternalQueueTimeUSecs ( const pge_network::PgeNetworkConnectionHandle & ,
bool  )
inlineoverridevirtual

Implements pge_network::PgeIServer.

Definition at line 243 of file PgeServerStub.h.

◆ getMsgAppId2StringMap()

std::map< pge_network::MsgApp::TMsgId, std::string > & pge_network::PgeServerStub::getMsgAppId2StringMap ( )
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 145 of file PgeServerStub.h.

◆ getPacketQueueSize()

std::size_t pge_network::PgeServerStub::getPacketQueueSize ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 93 of file PgeServerStub.h.

◆ getPendingReliableBytes()

int64_t pge_network::PgeServerStub::getPendingReliableBytes ( const pge_network::PgeNetworkConnectionHandle & ,
bool  )
inlineoverridevirtual

Implements pge_network::PgeIServer.

Definition at line 229 of file PgeServerStub.h.

◆ getPendingUnreliableBytes()

int64_t pge_network::PgeServerStub::getPendingUnreliableBytes ( const pge_network::PgeNetworkConnectionHandle & ,
bool  )
inlineoverridevirtual

Implements pge_network::PgeIServer.

Definition at line 222 of file PgeServerStub.h.

◆ getPing()

int pge_network::PgeServerStub::getPing ( const pge_network::PgeNetworkConnectionHandle & ,
bool  )
inlineoverridevirtual

Implements pge_network::PgeIServer.

Definition at line 187 of file PgeServerStub.h.

◆ getQualityLocal()

float pge_network::PgeServerStub::getQualityLocal ( const pge_network::PgeNetworkConnectionHandle & ,
bool  )
inlineoverridevirtual

Implements pge_network::PgeIServer.

Definition at line 194 of file PgeServerStub.h.

◆ getQualityRemote()

float pge_network::PgeServerStub::getQualityRemote ( const pge_network::PgeNetworkConnectionHandle & ,
bool  )
inlineoverridevirtual

Implements pge_network::PgeIServer.

Definition at line 201 of file PgeServerStub.h.

◆ getRxByteCount()

uint32_t pge_network::PgeServerStub::getRxByteCount ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 147 of file PgeServerStub.h.

◆ getRxByteRate()

float pge_network::PgeServerStub::getRxByteRate ( const pge_network::PgeNetworkConnectionHandle & ,
bool  )
inlineoverridevirtual

Implements pge_network::PgeIServer.

Definition at line 208 of file PgeServerStub.h.

◆ getRxMsgCount()

const std::map< pge_network::MsgApp::TMsgId, uint32_t > & pge_network::PgeServerStub::getRxMsgCount ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 141 of file PgeServerStub.h.

◆ getRxPacketCount()

uint32_t pge_network::PgeServerStub::getRxPacketCount ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 133 of file PgeServerStub.h.

◆ getRxPacketPerSecondCount()

uint32_t pge_network::PgeServerStub::getRxPacketPerSecondCount ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 137 of file PgeServerStub.h.

◆ getSentButUnAckedReliableBytes()

int64_t pge_network::PgeServerStub::getSentButUnAckedReliableBytes ( const pge_network::PgeNetworkConnectionHandle & ,
bool  )
inlineoverridevirtual

Implements pge_network::PgeIServer.

Definition at line 236 of file PgeServerStub.h.

◆ getTxByteCount()

uint32_t pge_network::PgeServerStub::getTxByteCount ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 148 of file PgeServerStub.h.

◆ getTxByteRate()

float pge_network::PgeServerStub::getTxByteRate ( const pge_network::PgeNetworkConnectionHandle & ,
bool  )
inlineoverridevirtual

Implements pge_network::PgeIServer.

Definition at line 215 of file PgeServerStub.h.

◆ getTxMsgCount()

const std::map< pge_network::MsgApp::TMsgId, uint32_t > & pge_network::PgeServerStub::getTxMsgCount ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 142 of file PgeServerStub.h.

◆ getTxPacketCount()

uint32_t pge_network::PgeServerStub::getTxPacketCount ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 134 of file PgeServerStub.h.

◆ getTxPacketPerSecondCount()

uint32_t pge_network::PgeServerStub::getTxPacketPerSecondCount ( ) const
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 138 of file PgeServerStub.h.

◆ initialize()

bool pge_network::PgeServerStub::initialize ( )
inlineoverridevirtual

Initialize the network instance.

Implements pge_network::PgeIServerClient.

Definition at line 53 of file PgeServerStub.h.

◆ isInitialized()

bool pge_network::PgeServerStub::isInitialized ( ) const
inlineoverridevirtual

Gets the state of the network instance.

Implements pge_network::PgeIServerClient.

Definition at line 73 of file PgeServerStub.h.

◆ operator=() [1/2]

PgeServerStub & pge_network::PgeServerStub::operator= ( const PgeServerStub & )
delete

◆ operator=() [2/2]

PgeServerStub && pge_network::PgeServerStub::operator= ( PgeServerStub && )
delete

◆ pollConnectionStateChanges()

void pge_network::PgeServerStub::pollConnectionStateChanges ( )
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 89 of file PgeServerStub.h.

◆ pollIncomingMessages()

bool pge_network::PgeServerStub::pollIncomingMessages ( )
inlineoverridevirtual

Moves incoming packets from the underlying network layer to PGE network layer as PgePackets.

Returns
True on success, false on error.

Implements pge_network::PgeIServerClient.

Definition at line 84 of file PgeServerStub.h.

◆ popFrontPacket()

pge_network::PgePacket pge_network::PgeServerStub::popFrontPacket ( )
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 98 of file PgeServerStub.h.

◆ send()

void pge_network::PgeServerStub::send ( const pge_network::PgePacket & pkt,
const pge_network::PgeNetworkConnectionHandle & connHandle = pge_network::ServerConnHandle )
inlineoverridevirtual

Sends the given packet to the network instance specified.

Parameters
pktThe packet to be sent.
connHandleThe addressed network instance, that can be either a server or client instance. The default parameter means the addressed instance is the server instance. If server is specified and current instance is the server, the packet will be injected to self instead of actually sending it to the lower network level.

Implements pge_network::PgeIServerClient.

Definition at line 113 of file PgeServerStub.h.

◆ sendToAll()

void pge_network::PgeServerStub::sendToAll ( const pge_network::PgePacket & pkt)
inlineoverridevirtual

Sends the given packet to all known network instances, including the server itself (self).

Basically equals to: send(pkt); sendToAllClientsExcept(pkt);

Parameters
pktThe packet to be sent.

Implements pge_network::PgeIServer.

Definition at line 172 of file PgeServerStub.h.

◆ sendToAllClientsExcept()

void pge_network::PgeServerStub::sendToAllClientsExcept ( const pge_network::PgePacket & pkt,
const pge_network::PgeNetworkConnectionHandle & exceptConnHandle = 0 )
inlineoverridevirtual

Sends the given packet to all client instances except the optionally specified client.

This function is never able to send to server, not even injecting, hence the name contains "Clients".

Parameters
pktThe packet to be sent.
exceptConnHandleThe server-side connection of handle of a client to which we DO NOT want to send the packet. Since this function never sends to server, we use pge_network::ServerConnHandle as default, in such case the packet is sent to all clients. Even if you specify a real server-side connection handle of a client, this packet will never be sent to server, that is why function name contains "Clients".

Implements pge_network::PgeIServer.

Definition at line 159 of file PgeServerStub.h.

◆ setDebugNickname()

void pge_network::PgeServerStub::setDebugNickname ( const pge_network::PgeNetworkConnectionHandle & connHandle,
const std::string & sNickname )
inlineoverridevirtual

Sets a debug helper name associated to the given connection handle.

Useful because it makes reading debug log easier when not only connection handle but also this debug helper name is also logged. Can be anything, for example it can be the same name as the player name on higher application level associated to this connection.

Parameters
connHandleThe connection for which we want to set the debug helper name. Cannot be ServerConnHandle.
sNicknameThe debug helper name we want to see associated to the specified connection in the debug logs.

Implements pge_network::PgeIServer.

Definition at line 185 of file PgeServerStub.h.

◆ shutdown()

bool pge_network::PgeServerStub::shutdown ( )
inlineoverridevirtual

This stops the network instance.

Implements pge_network::PgeIServerClient.

Definition at line 64 of file PgeServerStub.h.

◆ startListening()

bool pge_network::PgeServerStub::startListening ( const std::string & sAppVersion)
inlineoverridevirtual

Starts listening to incoming PgeClient connections.

If the function is successful, any call to the derived isListening() is expected to return true. Note: you can stop listening by invoking the derived disconnect() or shutdown() which are implemented already in hidden class.

Parameters
sAppVersionServer application version. We should fill it in if we expect connecting clients to have this same application version.
Returns
True on success, false otherwise or when it is already listening.

Implements pge_network::PgeIServer.

Definition at line 157 of file PgeServerStub.h.

◆ Update()

void pge_network::PgeServerStub::Update ( )
inlineoverridevirtual

Implements pge_network::PgeIServerClient.

Definition at line 81 of file PgeServerStub.h.

◆ WriteList()

void pge_network::PgeServerStub::WriteList ( ) const
inlineoverridevirtual

Writes statistics to console.

Implements pge_network::PgeIServerClient.

Definition at line 151 of file PgeServerStub.h.

Member Data Documentation

◆ m_bInited

bool pge_network::PgeServerStub::m_bInited {false}
private

Definition at line 261 of file PgeServerStub.h.

◆ m_cfgProfiles

PGEcfgProfiles& pge_network::PgeServerStub::m_cfgProfiles
private

Definition at line 259 of file PgeServerStub.h.

◆ m_mapTxMsgCount

std::map<pge_network::MsgApp::TMsgId, uint32_t> pge_network::PgeServerStub::m_mapTxMsgCount
private

Definition at line 264 of file PgeServerStub.h.

◆ m_nPktCountTx

uint32_t pge_network::PgeServerStub::m_nPktCountTx { 0 }
private

Definition at line 263 of file PgeServerStub.h.


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