// Join Session bool URadeGameInstance::JoinSession(TSharedPtr<const FUniqueNetId> UserId, FName SessionName, const FOnlineSessionSearchResult& SearchResult) { // Return bool bool bSuccessful = false; // Get OnlineSubsystem we want to work with IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get(); if (OnlineSub) { // Get SessionInterface from the OnlineSubsystem IOnlineSessionPtr Sessions = OnlineSub->GetSessionInterface(); if (Sessions.IsValid() && UserId.IsValid()) { // Set the Handle again OnJoinSessionCompleteDelegateHandle = Sessions->AddOnJoinSessionCompleteDelegate_Handle(OnJoinSessionCompleteDelegate); // Call the "JoinSession" Function with the passed "SearchResult". The "SessionSearch->SearchResults" can be used to get such a // "FOnlineSessionSearchResult" and pass it. Pretty straight forward! bSuccessful = Sessions->JoinSession(*UserId, SessionName, SearchResult); } } return bSuccessful; }
bool UtrnetDemoGameInstance::JoinSessionA(TSharedPtr<const FUniqueNetId> UserId, FName SessionName, const FOnlineSessionSearchResult& SearchResult) { // Get SessionInterface from the OnlineSubsystem IOnlineSessionPtr Sessions = GetSession(); if (!Sessions.IsValid() || !UserId.IsValid()) { return false; } // Set the Handle again OnJoinSessionCompleteDelegateHandle = Sessions->AddOnJoinSessionCompleteDelegate_Handle(OnJoinSessionCompleteDelegate); // Call the "JoinSession" Function with the passed "SearchResult". The "SessionSearch->SearchResults" can be used to get such a // "FOnlineSessionSearchResult" and pass it. Pretty straight forward! isLoading_ = true; return Sessions->JoinSession(*UserId, SessionName, SearchResult); }