void UOnlineSessionClient::OnSessionUserInviteAccepted(bool bWasSuccessful, int32 ControllerId, TSharedPtr<const FUniqueNetId> UserId, const FOnlineSessionSearchResult& SearchResult)
{
	UE_LOG(LogOnline, Verbose, TEXT("OnSessionUserInviteAccepted LocalUserNum: %d bSuccess: %d"), ControllerId, bWasSuccessful);
	// Don't clear invite accept delegate

	if (bWasSuccessful)
	{
		if (SearchResult.IsValid())
		{
			bIsFromInvite = true;
			JoinSession(GameSessionName, SearchResult);
		}
		else
		{
			UE_LOG(LogOnline, Warning, TEXT("Invite accept returned no search result."));
		}
	}
}
void UOnlineSessionClient::OnDestroyForJoinSessionComplete(FName SessionName, bool bWasSuccessful)
{
	UE_LOG(LogOnline, Verbose, TEXT("OnDestroyForJoinSessionComplete %s bSuccess: %d"), *SessionName.ToString(), bWasSuccessful);

	IOnlineSessionPtr SessionInt = GetSessionInt();

	if (SessionInt.IsValid())
	{
		SessionInt->ClearOnDestroySessionCompleteDelegate_Handle(OnDestroyForJoinSessionCompleteDelegateHandle);
	}

	if (bWasSuccessful)
	{
		JoinSession(SessionName, CachedSessionResult);
	}

	bHandlingDisconnect = false;
}
/**
 * Transition from destroying a session to joining a new one of the same name
 *
 * @param SessionName name of session recently destroyed
 * @param bWasSuccessful was the destroy attempt successful
 */
void UOnlineSessionClient::OnDestroyForJoinSessionComplete(FName SessionName, bool bWasSuccessful)
{
	UE_LOG(LogOnline, Verbose, TEXT("OnDestroyForJoinSessionComplete %s bSuccess: %d"), *SessionName.ToString(), bWasSuccessful);
	if (SessionInt.IsValid())
	{
		SessionInt->ClearOnDestroySessionCompleteDelegate(OnDestroyForJoinSessionCompleteDelegate);
	}

	if (bWasSuccessful)
	{
		int32 ControllerId = GetControllerId();
		if (ControllerId != INVALID_CONTROLLERID)
		{
			JoinSession(ControllerId, SessionName, CachedSessionResult);
		}
	}

	bHandlingDisconnect = false;
}
/**
 * Delegate fired when an invite request has been accepted (via external UI)
 *
 * @param LocalUserNum local user accepting invite
 * @param bWasSuccessful true if the async action completed without error, false if there was an error
 * @param SearchResult search result containing the invite data
 */
void UOnlineSessionClient::OnSessionInviteAccepted(int32 LocalUserNum, bool bWasSuccessful, const FOnlineSessionSearchResult& SearchResult)
{
	UE_LOG(LogOnline, Verbose, TEXT("OnSessionInviteAccepted LocalUserNum: %d bSuccess: %d"), LocalUserNum, bWasSuccessful);
	// Don't clear invite accept delegate

	if (bWasSuccessful)
	{
		if (SearchResult.IsValid())
		{
			bIsFromInvite = true;
			check(GetControllerId() == LocalUserNum);
			JoinSession(LocalUserNum, GameSessionName, SearchResult);
		}
		else
		{
			UE_LOG(LogOnline, Warning, TEXT("Invite accept returned no search result."));
		}
	}
}
void UNetGameInstance::OnSessionUserInviteAccepted(const bool bWasSuccesful, const int32 ControllerId, TSharedPtr<FUniqueNetId> UserId, const FOnlineSessionSearchResult &InviteResult)
{
	if (bWasSuccesful)
	{
		APlayerController* PC = GetWorld()->GetFirstPlayerController();
		const FBlueprintSessionResult& Result = FBlueprintSessionResult();
		FOnlineSessionSearchResult RResult = InviteResult;
		auto& IResult = RResult;
		//Result.OnlineResult = IResult;
		//this->SessionInviteAccepted(Result);
		auto Sessions = Online::GetSessionInterface();
		Sessions->AddOnJoinSessionCompleteDelegate(Delegate);
		Sessions->JoinSession(0, GameSessionName, InviteResult);
		GEngine->AddOnScreenDebugMessage(-1, 3000, FColor::Cyan, "InviteAccepted");
		FFrame::KismetExecutionMessage(TEXT("Yeeee Invite succesful"), ELogVerbosity::Warning);
	}
	else
	{
		FFrame::KismetExecutionMessage(TEXT("FUUU Invite not succesful"), ELogVerbosity::Warning);
	}
}
Beispiel #6
0
// Join Any Avaiable Online Game
void URadeGameInstance::JoinOnlineGame()
{
	ULocalPlayer* const Player = GetFirstGamePlayer();

	// Just a SearchResult where we can save the one we want to use, for the case we find more than one!
	FOnlineSessionSearchResult SearchResult;

	// If the Array is not empty, we can go through it
	if (SessionSearch->SearchResults.Num() > 0)
	{
		for (int32 i = 0; i < SessionSearch->SearchResults.Num(); i++)
		{
			// To avoid something crazy, we filter sessions from ourself
			if (SessionSearch->SearchResults[i].Session.OwningUserId != Player->GetPreferredUniqueNetId())
			{
				SearchResult = SessionSearch->SearchResults[i];

				JoinSession(Player->GetPreferredUniqueNetId(), GameSessionName, SearchResult);
				break;
			}
		}
	}
}
bool FOnlineSessionNull::JoinSession(const FUniqueNetId& PlayerId, FName SessionName, const FOnlineSessionSearchResult& DesiredSession)
{
	// Assuming player 0 should be OK here
	return JoinSession(0, SessionName, DesiredSession);
}
Beispiel #8
0
// Join Selected Online Session
void URadeGameInstance::JoinSelectedOnlineGame(FAvaiableSessionsData SessionData)
{
	ULocalPlayer* const Player = GetFirstGamePlayer();

	JoinSession(Player->GetPreferredUniqueNetId(), GameSessionName, SessionData.SessionData);
}