|
PGE API 0.4
PR00F's Game Engine full documentation
|
Server Wrapper for GameNetworkingSockets library. More...
Server Wrapper for GameNetworkingSockets library.
Definition at line 29 of file PgeGnsServer.h.
#include <PgeGnsServer.h>
Inheritance diagram for PgeGnsServer:Classes | |
| struct | TClient |
Public Member Functions | |
| virtual | ~PgeGnsServer () |
| virtual bool | destroy () override |
| Calls stopListening() and PgeGnsWrapper::destroy(). | |
| bool | startListening (const std::string &sAppVersion="") |
| Starts GameNetworkingSockets server listening to incoming GameNetworkingSockets client connections. | |
| bool | stopListening (const std::string &sExtraDebugText="") |
| Destroys all connections to clients and stops listening. | |
| bool | isListening () const |
| Gets if we are listening to incoming client connections. | |
| void | sendToClient (const HSteamNetConnection &conn, const pge_network::PgePacket &pkt) |
| void | sendToAllClientsExcept (const pge_network::PgePacket &pkt, const HSteamNetConnection &except=k_HSteamNetConnection_Invalid) |
| void | inject (const pge_network::PgePacket &pkt) |
| void | WriteServerClientList () |
| void | setClientDebugName (HSteamNetConnection connHandle, const char *nick) |
| const SteamNetConnectionRealTimeStatus_t & | getRealTimeStatus (const HSteamNetConnection &connHandle, bool bForceUpdate) |
| std::string | getDetailedConnectionStatus (const HSteamNetConnection &connHandle) const |
Public Member Functions inherited from PgeGnsWrapper | |
| virtual | ~PgeGnsWrapper () |
| bool | init () |
| Initializes the GameNetworkingSockets library. | |
| bool | isInitialized () const |
| Gets the state of initialization of the GameNetworkingSockets library. | |
| bool | pollIncomingMessages () |
| Moves incoming SteamNetworkingMessages from GameNetworkingSockets layer to m_queuePackets as PgePackets. | |
| void | pollConnectionStateChanges () |
| std::size_t | getPacketQueueSize () const |
| pge_network::PgePacket | popFrontPacket () noexcept(false) |
| std::set< pge_network::PgePktId > & | getAllowListedPgeMessages () |
| std::set< pge_network::MsgApp::TMsgId > & | getAllowListedAppMessages () |
| uint32_t | getRxPacketCount () const |
| uint32_t | getTxPacketCount () const |
| uint32_t | getInjectPacketCount () const |
| uint32_t | getRxPacketPerSecondCount () const |
| uint32_t | getTxPacketPerSecondCount () const |
| uint32_t | getInjectPacketPerSecondCount () const |
| const std::map< pge_network::MsgApp::TMsgId, uint32_t > & | getRxMsgCount () const |
| const std::map< pge_network::MsgApp::TMsgId, uint32_t > & | getTxMsgCount () const |
| const std::map< pge_network::MsgApp::TMsgId, uint32_t > & | getInjectMsgCount () const |
| std::map< pge_network::MsgApp::TMsgId, std::string > & | getMsgAppId2StringMap () |
| uint32_t | getRxByteCount () const |
| uint32_t | getTxByteCount () const |
| uint32_t | getInjectByteCount () const |
Static Public Member Functions | |
| static PgeGnsServer & | createAndGet (PGEcfgProfiles &cfgProfiles) |
| Creates and gets the singleton implementation instance. | |
Protected Member Functions | |
| virtual bool | pgeMessageIsHandledAtGnsLevel (const pge_network::PgePacket &pktReceivedFromClient) override |
| virtual int | receiveMessages (ISteamNetworkingMessage **pIncomingMsg, int nIncomingMsgArraySize) const override |
| virtual bool | validateSteamNetworkingMessage (const HSteamNetConnection &connHandle) const override |
| virtual void | updateIncomingPgePacket (pge_network::PgePacket &pkt, const HSteamNetConnection &connHandle) const override |
| virtual void | onSteamNetConnectionStatusChanged (SteamNetConnectionStatusChangedCallback_t *pInfo) override |
Protected Member Functions inherited from PgeGnsWrapper | |
| PgeGnsWrapper (PGEcfgProfiles &cfgProfiles) | |
| PgeGnsWrapper (const PgeGnsWrapper &) | |
| PgeGnsWrapper & | operator= (const PgeGnsWrapper &) |
| std::string | getStringByMsgAppId (const pge_network::MsgApp::TMsgId &id) const |
| std::string | getDetailedConnectionStatus (const HSteamNetConnection &connHandle) const |
| void | logDetailedConnectionStatus (const HSteamNetConnection &connHandle) const |
Private Types | |
| typedef std::map< HSteamNetConnection, TClient > | SteamNetConnHandle2TClientMap |
Private Member Functions | |
| PgeGnsServer (PGEcfgProfiles &cfgProfiles) | |
| PgeGnsServer (const PgeGnsServer &) | |
| PgeGnsServer & | operator= (const PgeGnsServer &) |
| const TClient * | isClientConnectionHandleValid (const HSteamNetConnection &connHandle) const |
| TClient * | isClientConnectionHandleValid (const HSteamNetConnection &connHandle) |
Private Attributes | |
| uint16 | m_nPort |
| HSteamListenSocket | m_hListenSock |
| HSteamNetPollGroup | m_hPollGroup |
| SteamNetConnHandle2TClientMap | m_mapClients |
Additional Inherited Members | |
Static Public Attributes inherited from PgeGnsWrapper | |
| static const uint16 | DEFAULT_SERVER_PORT = 27020 |
Static Protected Member Functions inherited from PgeGnsWrapper | |
| static void | steamNetConnectionStatusChangedCallback (SteamNetConnectionStatusChangedCallback_t *pInfo) |
Protected Attributes inherited from PgeGnsWrapper | |
| PGEcfgProfiles & | m_cfgProfiles |
| ISteamNetworkingSockets * | m_pInterface |
| std::deque< pge_network::PgePacket > | m_queuePackets |
| std::set< pge_network::PgePktId > | m_allowListedPgeMessages |
| std::set< pge_network::MsgApp::TMsgId > | m_allowListedAppMessages |
| uint32_t | m_nRxPktCount |
| uint32_t | m_nTxPktCount |
| uint32_t | m_nInjectPktCount |
| std::chrono::time_point< std::chrono::steady_clock > | m_time1stRxPkt |
| std::chrono::time_point< std::chrono::steady_clock > | m_time1stTxPkt |
| std::chrono::time_point< std::chrono::steady_clock > | m_time1stInjectPkt |
| std::map< pge_network::MsgApp::TMsgId, uint32_t > | m_nRxMsgCount |
| std::map< pge_network::MsgApp::TMsgId, uint32_t > | m_nTxMsgCount |
| std::map< pge_network::MsgApp::TMsgId, uint32_t > | m_nInjectMsgCount |
| std::map< pge_network::MsgApp::TMsgId, std::string > | m_mapMsgAppId2String |
| uint32_t | m_nRxByteCount |
| uint32_t | m_nTxByteCount |
| uint32_t | m_nInjectByteCount |
| std::string | m_sAppVersion |
| Expected client app version in case of server instance, or simply client app version in case of client instance. | |
Static Protected Attributes inherited from PgeGnsWrapper | |
| static PgeGnsWrapper * | s_pCallbackInstance = nullptr |
|
private |
Definition at line 114 of file PgeGnsServer.h.
|
virtual |
Definition at line 38 of file PgeGnsServer.cpp.
|
explicitprivate |
Definition at line 600 of file PgeGnsServer.cpp.
|
private |
Definition at line 608 of file PgeGnsServer.cpp.
|
static |
Creates and gets the singleton implementation instance.
Creates and gets the singleton instance.
Definition at line 32 of file PgeGnsServer.cpp.
|
overridevirtual |
Calls stopListening() and PgeGnsWrapper::destroy().
Reimplemented from PgeGnsWrapper.
Definition at line 43 of file PgeGnsServer.cpp.
| std::string PgeGnsServer::getDetailedConnectionStatus | ( | const HSteamNetConnection & | connHandle | ) | const |
Definition at line 352 of file PgeGnsServer.cpp.
| const SteamNetConnectionRealTimeStatus_t & PgeGnsServer::getRealTimeStatus | ( | const HSteamNetConnection & | connHandle, |
| bool | bForceUpdate ) |
Definition at line 334 of file PgeGnsServer.cpp.
| void PgeGnsServer::inject | ( | const pge_network::PgePacket & | pkt | ) |
Definition at line 278 of file PgeGnsServer.cpp.
|
private |
Definition at line 645 of file PgeGnsServer.cpp.
|
private |
Definition at line 619 of file PgeGnsServer.cpp.
| bool PgeGnsServer::isListening | ( | ) | const |
Gets if we are listening to incoming client connections.
Basically it always returns true after a successful call to startListening(), and returns false after a call to stopListening().
Definition at line 192 of file PgeGnsServer.cpp.
|
overrideprotectedvirtual |
Implements PgeGnsWrapper.
Definition at line 446 of file PgeGnsServer.cpp.
|
private |
Definition at line 614 of file PgeGnsServer.cpp.
|
overrideprotectedvirtual |
Implements PgeGnsWrapper.
Definition at line 368 of file PgeGnsServer.cpp.
|
overrideprotectedvirtual |
Implements PgeGnsWrapper.
Definition at line 416 of file PgeGnsServer.cpp.
| void PgeGnsServer::sendToAllClientsExcept | ( | const pge_network::PgePacket & | pkt, |
| const HSteamNetConnection & | except = k_HSteamNetConnection_Invalid ) |
Definition at line 257 of file PgeGnsServer.cpp.
| void PgeGnsServer::sendToClient | ( | const HSteamNetConnection & | conn, |
| const pge_network::PgePacket & | pkt ) |
Definition at line 197 of file PgeGnsServer.cpp.
| void PgeGnsServer::setClientDebugName | ( | HSteamNetConnection | connHandle, |
| const char * | nick ) |
Definition at line 319 of file PgeGnsServer.cpp.
| bool PgeGnsServer::startListening | ( | const std::string & | sAppVersion = "" | ) |
Starts GameNetworkingSockets server listening to incoming GameNetworkingSockets client connections.
First you need to initialize GameNetworkingSockets subsystem by calling PgeGnsWrapper::init(), and only after that you can try start listening. After a successful call, isListening() is expected to return true.
| sAppVersion | Server application version. We should fill it in if we expect connecting clients to have this same application version. |
Definition at line 54 of file PgeGnsServer.cpp.
| bool PgeGnsServer::stopListening | ( | const std::string & | sExtraDebugText = "" | ) |
Destroys all connections to clients and stops listening.
On success, startListening() can be invoked again. After a successful call, isListening() is expected to return false, but PgeGnsWrapper::isInitialized() state stays unchanged.
| sExtraDebugText | An optional text that will be sent to the other side and will be logged to help debugging. |
Definition at line 124 of file PgeGnsServer.cpp.
|
overrideprotectedvirtual |
Implements PgeGnsWrapper.
Definition at line 441 of file PgeGnsServer.cpp.
|
overrideprotectedvirtual |
Implements PgeGnsWrapper.
Definition at line 423 of file PgeGnsServer.cpp.
| void PgeGnsServer::WriteServerClientList | ( | ) |
Definition at line 300 of file PgeGnsServer.cpp.
|
private |
Definition at line 118 of file PgeGnsServer.h.
|
private |
Definition at line 119 of file PgeGnsServer.h.
|
private |
Definition at line 121 of file PgeGnsServer.h.
|
private |
Definition at line 116 of file PgeGnsServer.h.