当前位置: 首页>>代码示例>>C++>>正文


C++ IOnlineSessionPtr::FindSessions方法代码示例

本文整理汇总了C++中IOnlineSessionPtr::FindSessions方法的典型用法代码示例。如果您正苦于以下问题:C++ IOnlineSessionPtr::FindSessions方法的具体用法?C++ IOnlineSessionPtr::FindSessions怎么用?C++ IOnlineSessionPtr::FindSessions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IOnlineSessionPtr的用法示例。


在下文中一共展示了IOnlineSessionPtr::FindSessions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindSessions

/**
*	Find an online session
*
*	@param UserId user that initiated the request
*	@param SessionName name of session this search will generate
*	@param bIsLAN are we searching LAN matches
*	@param bIsPresence are we searching presence sessions
*/
void URadeGameInstance::FindSessions(TSharedPtr<const FUniqueNetId> UserId, FName SessionName, bool bIsLAN, bool bIsPresence)
{
	// Get the OnlineSubsystem we want to work with
	IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();

	if (OnlineSub)
	{
		bIsSearchingSession = true;
		// Get the SessionInterface from our OnlineSubsystem
		IOnlineSessionPtr Sessions = OnlineSub->GetSessionInterface();

		if (Sessions.IsValid() && UserId.IsValid())
		{
			/*
			Fill in all the SearchSettings, like if we are searching for a LAN game and how many results we want to have!
			*/
			SessionSearch = MakeShareable(new FOnlineSessionSearch());

			SessionSearch->bIsLanQuery = bIsLAN;
			SessionSearch->MaxSearchResults = 20;
			SessionSearch->PingBucketSize = 50;

			// We only want to set this Query Setting if "bIsPresence" is true
			if (bIsPresence)
			{
				SessionSearch->QuerySettings.Set(SEARCH_PRESENCE, bIsPresence, EOnlineComparisonOp::Equals);
			}

			TSharedRef<FOnlineSessionSearch> SearchSettingsRef = SessionSearch.ToSharedRef();

			// Set the Delegate to the Delegate Handle of the FindSession function
			OnFindSessionsCompleteDelegateHandle = Sessions->AddOnFindSessionsCompleteDelegate_Handle(OnFindSessionsCompleteDelegate);

			// Finally call the SessionInterface function. The Delegate gets called once this is finished
			Sessions->FindSessions(*UserId, SearchSettingsRef);
		}
	}
	else
	{
		// If something goes wrong, just call the Delegate Function directly with "false".
		OnFindSessionsComplete(false);
	}
}
开发者ID:ZioYuri78,项目名称:Rade,代码行数:51,代码来源:RadeGameInstance.cpp

示例2: FindQosServersByRegion

bool UQosEvaluator::FindQosServersByRegion(int32 RegionIdx, FOnQosSearchComplete InCompletionDelegate)
{
    bool bSuccess = false;
    if (Datacenters.IsValidIndex(RegionIdx))
    {
        FQosRegionInfo& Datacenter = Datacenters[RegionIdx];
        Datacenter.Reset();

        IOnlineSubsystem* OnlineSub = Online::GetSubsystem(GetWorld());
        if (OnlineSub)
        {
            IOnlineSessionPtr SessionInt = OnlineSub->GetSessionInterface();
            if (SessionInt.IsValid())
            {
                if (!Datacenter.Region.RegionId.IsEmpty())
                {
                    const TSharedRef<FOnlineSessionSearch> QosSearchParams = MakeShareable(new FOnlineSessionSearchQos());
                    QosSearchParams->QuerySettings.Set(SETTING_REGION, Datacenter.Region.RegionId, EOnlineComparisonOp::Equals);

                    QosSearchQuery = QosSearchParams;

                    FOnFindSessionsCompleteDelegate OnFindDatacentersCompleteDelegate = FOnFindSessionsCompleteDelegate::CreateUObject(this, &ThisClass::OnFindQosServersByRegionComplete, RegionIdx, InCompletionDelegate);
                    OnFindDatacentersCompleteDelegateHandle = SessionInt->AddOnFindSessionsCompleteDelegate_Handle(OnFindDatacentersCompleteDelegate);

                    SessionInt->FindSessions(ControllerId, QosSearchParams);
                }
                else
                {
                    OnFindQosServersByRegionComplete(false, RegionIdx, InCompletionDelegate);
                }
                bSuccess = true;
            }
        }
    }

    return bSuccess;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:37,代码来源:QosEvaluator.cpp


注:本文中的IOnlineSessionPtr::FindSessions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。