本文整理汇总了C++中IOnlineSubsystem::GetAppId方法的典型用法代码示例。如果您正苦于以下问题:C++ IOnlineSubsystem::GetAppId方法的具体用法?C++ IOnlineSubsystem::GetAppId怎么用?C++ IOnlineSubsystem::GetAppId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOnlineSubsystem
的用法示例。
在下文中一共展示了IOnlineSubsystem::GetAppId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StartupModule
void FDedicatedServerModule::StartupModule()
{
#if WITH_SERVER_CODE
if( IsRunningDedicatedServer() )
{
bool bUseConsole = FParse::Param( FCommandLine::Get(), TEXT( "console" ) );
if( bUseConsole && !TIsSame<decltype( GLogConsole ), FServerConsole>::Value )
{
g_pConsole = new FServerConsole();
if( g_pConsole.IsValid() )
{
g_pConsole->Show( true );
GLog->RemoveOutputDevice( GLogConsole );
GLogConsole = g_pConsole.GetOwnedPointer();
GLog->AddOutputDevice( GLogConsole );
}
m_hTick = Async<void>( EAsyncExecution::Thread, [this]() -> void
{
while( !m_bShutdown )
{
if( g_pConsole.IsValid() && g_pConsole->IsShown() ) g_pConsole->Tick();
}
} );
}
bool bUseAutoUpdate = FParse::Param( FCommandLine::Get(), TEXT( "autoupdate" ) );
if( bUseAutoUpdate )
{
FString sVersion = GConfig->GetStr( TEXT( "OnlineSubsystemSteam" ), TEXT( "GameVersion" ), GEngineIni );
IOnlineSubsystem* pSteam = IOnlineSubsystem::Get( STEAM_SUBSYSTEM );
m_hAutoUpdateTicker = FTicker::GetCoreTicker().AddTicker( FTickerDelegate::CreateLambda( [=]( float fDeltaTime ) -> bool
{
UE_LOG( LogDedicatedServer, Display, TEXT( "Checking for updates..." ) );
// ToDo: Do we have alternatives to the Steam API check?
if( pSteam )
{
TSharedRef<class IHttpRequest> hHTTPRequest = FHttpModule::Get().CreateRequest();
// Note: UpToDateCheck is expecting a uint32 where the rest of Steamworks uses a semver / integer string, so we have to convert it here...
hHTTPRequest->SetURL( FString::Printf( TEXT( "https://api.steampowered.com/ISteamApps/UpToDateCheck/v0001/?appid=%s&version=%s" ), *pSteam->GetAppId(), *sVersion.Replace( TEXT( "." ), TEXT( "" ) ) ) );
hHTTPRequest->SetVerb( TEXT( "GET" ) );
hHTTPRequest->OnProcessRequestComplete().BindLambda( [=]( FHttpRequestPtr pHTTPRequest, FHttpResponsePtr pHTTPResponse, bool bSucceeded ) -> void
{
if( bSucceeded && pHTTPResponse->GetResponseCode() == EHttpResponseCodes::Ok )
{
TSharedPtr<FJsonObject> pJSONObject;
TSharedRef<TJsonReader<>> hJSONReader = TJsonReaderFactory<>::Create( pHTTPResponse->GetContentAsString() );
if( FJsonSerializer::Deserialize( hJSONReader, pJSONObject ) && pJSONObject.IsValid() )
{
TSharedPtr<FJsonObject> pResponse = pJSONObject->GetObjectField( TEXT( "response" ) );
if( pResponse.IsValid() && pResponse->GetBoolField( TEXT( "success" ) ) )
{
if( !pResponse->GetBoolField( TEXT( "up_to_date" ) ) )
{
// ToDo: find a better way which also respects the message field...
FString sRequiredVersion = FString::FromInt( pResponse->GetIntegerField( TEXT( "required_version" ) ) );
UE_LOG( LogDedicatedServer, Warning, TEXT( "The server is outdated( %s -> %s ), restarting..." ), *sVersion, ( sRequiredVersion.Equals( sVersion ) ? *sRequiredVersion : *Str2SemVer( sRequiredVersion ) )/*, pResponse->GetStringField( "message" )*/ );
GIsRequestingExit = true;
m_bShutdown = true;
}
else UE_LOG( LogDedicatedServer, Display, TEXT( "The server is using the most recent version( %s )" ), *sVersion );
}
}
}
} );
hHTTPRequest->ProcessRequest();
}
if( m_bShutdown ) return false;
return true;
} ), 60.0f );
}
}
#endif
}