void UOnlineSessionClient::RegisterOnlineDelegates() { OnJoinSessionCompleteDelegate = FOnJoinSessionCompleteDelegate ::CreateUObject(this, &ThisClass::OnJoinSessionComplete); OnEndForJoinSessionCompleteDelegate = FOnEndSessionCompleteDelegate ::CreateUObject(this, &ThisClass::OnEndForJoinSessionComplete); OnDestroyForJoinSessionCompleteDelegate = FOnDestroySessionCompleteDelegate::CreateUObject(this, &ThisClass::OnDestroyForJoinSessionComplete); OnDestroyForMainMenuCompleteDelegate = FOnDestroySessionCompleteDelegate::CreateUObject(this, &ThisClass::OnDestroyForMainMenuComplete); OnSessionUserInviteAcceptedDelegate = FOnSessionUserInviteAcceptedDelegate::CreateUObject(this, &ThisClass::OnSessionUserInviteAccepted); IOnlineSessionPtr SessionInt = GetSessionInt(); if (SessionInt.IsValid()) { OnSessionUserInviteAcceptedDelegateHandle = SessionInt->AddOnSessionUserInviteAcceptedDelegate_Handle(OnSessionUserInviteAcceptedDelegate); } }
void UGameInstance::Init() { ReceiveInit(); const auto OnlineSub = IOnlineSubsystem::Get(); if (OnlineSub != nullptr) { IOnlineSessionPtr SessionInt = OnlineSub->GetSessionInterface(); if (SessionInt.IsValid()) { SessionInt->AddOnSessionUserInviteAcceptedDelegate_Handle(FOnSessionUserInviteAcceptedDelegate::CreateUObject(this, &UGameInstance::HandleSessionUserInviteAccepted)); } } UClass* SpawnClass = GetOnlineSessionClass(); OnlineSession = NewObject<UOnlineSession>(this, SpawnClass); if (OnlineSession) { OnlineSession->RegisterOnlineDelegates(); } }