Problem: The SteamNetworkingSockets()
call from the GameNetworkingSockets library is returning nullptr
.
Fix: You are probably missing some initialization prior to that.
Look at the function InitSteamDatagramConnectionSockets
from the repo's example_chat.cpp
:
static void InitSteamDatagramConnectionSockets()
{
#ifdef STEAMNETWORKINGSOCKETS_OPENSOURCE
SteamDatagramErrMsg errMsg;
if ( !GameNetworkingSockets_Init( nullptr, errMsg ) )
FatalError( "GameNetworkingSockets_Init failed. %s", errMsg );
#else
SteamDatagram_SetAppID( 570 ); // Just set something, doesn't matter what
SteamDatagram_SetUniverse( false, k_EUniverseDev );
SteamDatagramErrMsg errMsg;
if ( !SteamDatagramClient_Init( errMsg ) )
FatalError( "SteamDatagramClient_Init failed. %s", errMsg );
// Disable authentication when running with Steam, for this
// example, since we're not a real app.
//
// Authentication is disabled automatically in the open-source
// version since we don't have a trusted third party to issue
// certs.
SteamNetworkingUtils()->SetGlobalConfigValueInt32( k_ESteamNetworkingConfig_IP_AllowWithoutAuth, 1 );
#endif
g_logTimeZero = SteamNetworkingUtils()->GetLocalTimestamp();
SteamNetworkingUtils()->SetDebugOutputFunction( k_ESteamNetworkingSocketsDebugOutputType_Msg, DebugOutput );
}