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

Detailed Description

Definition at line 25 of file PgeNetwork.cpp.

+ Inheritance diagram for PgeNetworkImpl:

Public Member Functions

virtual ~PgeNetworkImpl ()
 Calls shutdown().
 
bool initialize () override
 Initialize the networking subsystem.
 
bool shutdown () override
 Stops the networking subsystem.
 
bool isInitialized () const override
 Gets the state of the networking subsystem.
 
bool reinitialize () override
 Stop and then initialize the networking subsystem.
 
void disconnect (const std::string &sExtraDebugText="") override
 Disconnects the initialized networking subsystem.
 
bool isServer () const override
 Returns whether the initialized network subsystem should be the server instance.
 
void Update () override
 Handles connection state changes and forwards messages to the application.
 
pge_network::PgeIServerClientgetServerClientInstance () override
 Returns access to the initialized networking subsystem.
 
pge_network::PgeIClientgetClient () override
 Returns the client instance.
 
pge_network::PgeIServergetServer () override
 Returns the server instance.
 
void WriteList () const override
 Writes statistics to console.
 
- Public Member Functions inherited from pge_network::PgeNetwork
CConsole & getConsole () const
 Returns access to console preset with logger module name as this class.
 
- Public Member Functions inherited from pge_network::PgeINetwork

Private Member Functions

 PgeNetworkImpl (PGEcfgProfiles &cfgProfiles)
 NULLs members only.
 
 PgeNetworkImpl (const PgeNetworkImpl &)
 
PgeNetworkImploperator= (const PgeNetworkImpl &)
 

Private Attributes

PGEcfgProfilesm_cfgProfiles
 
pge_network::PgeIServerClientm_pServerClient
 
pge_network::PgeIClientm_pClient
 
pge_network::PgeIServerm_pServer
 
bool m_bServer
 

Friends

class pge_network::PgeNetwork
 

Additional Inherited Members

- Static Public Member Functions inherited from pge_network::PgeNetwork
static PgeINetworkcreateAndGet (PGEcfgProfiles &cfgProfiles)
 Creates and gets the singleton implementation instance.
 
- Static Public Member Functions inherited from pge_network::PgeINetwork
static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 
- Static Public Attributes inherited from pge_network::PgeINetwork
static constexpr char * CVAR_NET_SERVER = "net_server"
 

Constructor & Destructor Documentation

◆ ~PgeNetworkImpl()

PgeNetworkImpl::~PgeNetworkImpl ( )
virtual

Calls shutdown().

Definition at line 70 of file PgeNetwork.cpp.

◆ PgeNetworkImpl() [1/2]

PgeNetworkImpl::PgeNetworkImpl ( PGEcfgProfiles & cfgProfiles)
explicitprivate

NULLs members only.

Definition at line 270 of file PgeNetwork.cpp.

◆ PgeNetworkImpl() [2/2]

PgeNetworkImpl::PgeNetworkImpl ( const PgeNetworkImpl & other)
private

Definition at line 281 of file PgeNetwork.cpp.

Member Function Documentation

◆ disconnect()

void PgeNetworkImpl::disconnect ( const std::string & sExtraDebugText = "")
overridevirtual

Disconnects the initialized networking subsystem.

After a disconnect(), the initialized networking subsystem can be connected again:

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

Implements pge_network::PgeINetwork.

Definition at line 166 of file PgeNetwork.cpp.

◆ getClient()

pge_network::PgeIClient & PgeNetworkImpl::getClient ( )
overridevirtual

Returns the client instance.

This is always a valid reference, even if getServerClientInstance() returns nullptr. This is because both client and server instances are always created, however neither of them might be initialized. This function is for convenience, since it is similar to: dynamic_cast<pge_network::PgeClient*>(getServerClientInstance())

Returns
The client instance which might or might not be initialized.

Implements pge_network::PgeINetwork.

Definition at line 222 of file PgeNetwork.cpp.

◆ getServer()

pge_network::PgeIServer & PgeNetworkImpl::getServer ( )
overridevirtual

Returns the server instance.

This is always a valid reference, even if getServerClientInstance() returns nullptr. This is because both client and server instances are always created, however neither of them might be initialized. This function is for convenience, since it is similar to: dynamic_cast<pge_network::PgeServer*>(getServerClientInstance())

Returns
The server instance which might or might not be initialized.

Implements pge_network::PgeINetwork.

Definition at line 236 of file PgeNetwork.cpp.

◆ getServerClientInstance()

pge_network::PgeIServerClient * PgeNetworkImpl::getServerClientInstance ( )
overridevirtual

Returns access to the initialized networking subsystem.

This is either the server or the client instance, or none of them.

Returns
Either the server or the client instance, depending on which is initialized. Nullptr if not yet initialized (when isInitialized() is false).

Implements pge_network::PgeINetwork.

Definition at line 208 of file PgeNetwork.cpp.

◆ initialize()

bool PgeNetworkImpl::initialize ( )
overridevirtual

Initialize the networking subsystem.

Either the server or a client instance will be initialized.

Returns
The result of the initialization. True on success, false otherwise.

Implements pge_network::PgeINetwork.

Definition at line 81 of file PgeNetwork.cpp.

◆ isInitialized()

bool PgeNetworkImpl::isInitialized ( ) const
overridevirtual

Gets the state of the networking subsystem.

Returns
True if the networking subsystem is successfully initialized, false before initialization or after shutdown.

Implements pge_network::PgeINetwork.

Definition at line 152 of file PgeNetwork.cpp.

◆ isServer()

bool PgeNetworkImpl::isServer ( ) const
overridevirtual

Returns whether the initialized network subsystem should be the server instance.

Note: this has nothing to do with the actual initialization state of the network subsystem, this is just the desired configuration.

Returns
True if initialized network subsystem should be the server instance, false if it should be the client instance.

Implements pge_network::PgeINetwork.

Definition at line 180 of file PgeNetwork.cpp.

◆ operator=()

PgeNetworkImpl & PgeNetworkImpl::operator= ( const PgeNetworkImpl & )
private

Definition at line 291 of file PgeNetwork.cpp.

◆ reinitialize()

bool PgeNetworkImpl::reinitialize ( )
overridevirtual

Stop and then initialize the networking subsystem.

Useful when we change the value of CVAR_NET_SERVER and want this change to take effect.

Returns
True on successful reinitialization, false otherwise.

Implements pge_network::PgeINetwork.

Definition at line 137 of file PgeNetwork.cpp.

◆ shutdown()

bool PgeNetworkImpl::shutdown ( )
overridevirtual

Stops the networking subsystem.

No effect before initialization. After shutdown, initialize() can be called again.

Returns
True on successful shutdown, false otherwise.

Implements pge_network::PgeINetwork.

Definition at line 119 of file PgeNetwork.cpp.

◆ Update()

void PgeNetworkImpl::Update ( )
overridevirtual

Handles connection state changes and forwards messages to the application.

Application can process these messages by overriding PGE::onPacketReceived().

Implements pge_network::PgeINetwork.

Definition at line 189 of file PgeNetwork.cpp.

◆ WriteList()

void PgeNetworkImpl::WriteList ( ) const
overridevirtual

Writes statistics to console.

Implements pge_network::PgeINetwork.

Definition at line 244 of file PgeNetwork.cpp.

Friends And Related Symbol Documentation

◆ pge_network::PgeNetwork

friend class pge_network::PgeNetwork
friend

Definition at line 60 of file PgeNetwork.cpp.

Member Data Documentation

◆ m_bServer

bool PgeNetworkImpl::m_bServer
private

Definition at line 54 of file PgeNetwork.cpp.

◆ m_cfgProfiles

PGEcfgProfiles& PgeNetworkImpl::m_cfgProfiles
private

Definition at line 50 of file PgeNetwork.cpp.

◆ m_pClient

pge_network::PgeIClient& PgeNetworkImpl::m_pClient
private

Definition at line 52 of file PgeNetwork.cpp.

◆ m_pServer

pge_network::PgeIServer& PgeNetworkImpl::m_pServer
private

Definition at line 53 of file PgeNetwork.cpp.

◆ m_pServerClient

pge_network::PgeIServerClient* PgeNetworkImpl::m_pServerClient
private

Definition at line 51 of file PgeNetwork.cpp.


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