PGE API 0.4
PR00F's Game Engine full documentation
|
Client Wrapper for GameNetworkingSockets library. More...
Client Wrapper for GameNetworkingSockets library.
Definition at line 29 of file PgeGnsClient.h.
#include <PgeGnsClient.h>
Public Member Functions | |
virtual | ~PgeGnsClient () |
virtual bool | destroy () override |
Calls disconnectClient() and PgeGnsWrapper::destroy(). | |
bool | connectToServer (const std::string &sServerAddress, const std::string &sAppVersion="") |
Sets up GameNetworkingSockets client connection to a GameNetworkingSockets server instance. | |
bool | disconnectClient (const std::string &sExtraDebugText="") |
Disconnects the client from the server. | |
bool | isConnected () const |
Gets if we are logically connected to a server. | |
const HSteamNetConnection & | getConnectionHandle () const |
const HSteamNetConnection & | getConnectionHandleServerSide () const |
const char * | getServerAddress () const |
void | sendToServer (const pge_network::PgePacket &pkt) |
const SteamNetConnectionRealTimeStatus_t & | getRealTimeStatus (bool bForceUpdate) |
std::string | getDetailedConnectionStatus () const |
![]() | |
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 PgeGnsClient & | createAndGet (PGEcfgProfiles &cfgProfiles) |
Creates and gets the singleton implementation instance. | |
Protected Member Functions | |
virtual bool | pgeMessageIsHandledAtGnsLevel (const pge_network::PgePacket &pktReceivedFromServer) |
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 |
![]() | |
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 Member Functions | |
PgeGnsClient (PGEcfgProfiles &cfgProfiles) | |
PgeGnsClient (const PgeGnsClient &) | |
PgeGnsClient & | operator= (const PgeGnsClient &) |
Private Attributes | |
SteamNetworkingIPAddr | m_addrServer |
char | m_szAddr [SteamNetworkingIPAddr::k_cchMaxString] |
HSteamNetConnection | m_hConnection |
HSteamNetConnection | m_hConnectionServerSide |
SteamNetConnectionRealTimeStatus_t | m_connRtStatus |
Additional Inherited Members | |
![]() | |
static const uint16 | DEFAULT_SERVER_PORT = 27020 |
![]() | |
static void | steamNetConnectionStatusChangedCallback (SteamNetConnectionStatusChangedCallback_t *pInfo) |
![]() | |
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 PgeGnsWrapper * | s_pCallbackInstance = nullptr |
|
virtual |
Definition at line 38 of file PgeGnsClient.cpp.
|
explicitprivate |
Definition at line 273 of file PgeGnsClient.cpp.
|
private |
Definition at line 282 of file PgeGnsClient.cpp.
bool PgeGnsClient::connectToServer | ( | const std::string & | sServerAddress, |
const std::string & | sAppVersion = "" ) |
Sets up GameNetworkingSockets client connection to a GameNetworkingSockets server instance.
First you need to initialize GameNetworkingSockets subsystem by calling PgeGnsWrapper::init(), and only after that you can try establishing connection to a server instance. After a successful call, isConnected() is expected to return true.
sServerAddress | IPv4 or IPv6 address of GameNetworkingSockets server we want to connect to. |
sAppVersion | Client application version. If server expects a specific client version, we should fill it here. |
Definition at line 58 of file PgeGnsClient.cpp.
|
static |
Creates and gets the singleton implementation instance.
Creates and gets the singleton instance.
Definition at line 32 of file PgeGnsClient.cpp.
|
overridevirtual |
Calls disconnectClient() and PgeGnsWrapper::destroy().
Normally this should be called only once: exiting the application. You don't need to call this just for disconnecting the client, for that use disconnectClient().
After a call to destroy(), and before you can connect to a server again, you need to reinitialize the GameNetworkingSockets subsystem by calling PgeGnsWrapper::init().
Reimplemented from PgeGnsWrapper.
Definition at line 43 of file PgeGnsClient.cpp.
bool PgeGnsClient::disconnectClient | ( | const std::string & | sExtraDebugText = "" | ) |
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.
After a successful call, isConnected() is expected to return false, but PgeGnsWrapper::isInitialized() state stays unchanged, so connectToServer() can be invoked again.
sExtraDebugText | An optional text that will be sent to the other side and will be logged to help debugging. |
Definition at line 125 of file PgeGnsClient.cpp.
const HSteamNetConnection & PgeGnsClient::getConnectionHandle | ( | ) | const |
Definition at line 169 of file PgeGnsClient.cpp.
const HSteamNetConnection & PgeGnsClient::getConnectionHandleServerSide | ( | ) | const |
Definition at line 174 of file PgeGnsClient.cpp.
std::string PgeGnsClient::getDetailedConnectionStatus | ( | ) | const |
Definition at line 255 of file PgeGnsClient.cpp.
const SteamNetConnectionRealTimeStatus_t & PgeGnsClient::getRealTimeStatus | ( | bool | bForceUpdate | ) |
Definition at line 238 of file PgeGnsClient.cpp.
const char * PgeGnsClient::getServerAddress | ( | ) | const |
Definition at line 179 of file PgeGnsClient.cpp.
bool PgeGnsClient::isConnected | ( | ) | const |
Gets if we are logically connected to a server.
Basically it always returns true after a successful call to connectToServer(), and returns false after a call to disconnectClient().
Definition at line 164 of file PgeGnsClient.cpp.
|
overrideprotectedvirtual |
Implements PgeGnsWrapper.
Definition at line 316 of file PgeGnsClient.cpp.
|
private |
Definition at line 288 of file PgeGnsClient.cpp.
|
protectedvirtual |
Implements PgeGnsWrapper.
Definition at line 293 of file PgeGnsClient.cpp.
|
overrideprotectedvirtual |
Implements PgeGnsWrapper.
Definition at line 299 of file PgeGnsClient.cpp.
void PgeGnsClient::sendToServer | ( | const pge_network::PgePacket & | pkt | ) |
Definition at line 184 of file PgeGnsClient.cpp.
|
overrideprotectedvirtual |
Implements PgeGnsWrapper.
Definition at line 311 of file PgeGnsClient.cpp.
|
overrideprotectedvirtual |
Implements PgeGnsWrapper.
Definition at line 306 of file PgeGnsClient.cpp.
|
private |
Definition at line 118 of file PgeGnsClient.h.
|
private |
Definition at line 131 of file PgeGnsClient.h.
|
private |
Definition at line 120 of file PgeGnsClient.h.
|
private |
Definition at line 129 of file PgeGnsClient.h.
|
private |
Definition at line 119 of file PgeGnsClient.h.