本文整理汇总了C++中IOnlineSessionPtr::IsPlayerInSession方法的典型用法代码示例。如果您正苦于以下问题:C++ IOnlineSessionPtr::IsPlayerInSession方法的具体用法?C++ IOnlineSessionPtr::IsPlayerInSession怎么用?C++ IOnlineSessionPtr::IsPlayerInSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOnlineSessionPtr
的用法示例。
在下文中一共展示了IOnlineSessionPtr::IsPlayerInSession方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsPlayerInSession
void UAdvancedSessionsLibrary::IsPlayerInSession(const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession)
{
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
if (!SessionInterface.IsValid())
{
UE_LOG(AdvancedSessionsLog, Warning, TEXT("IsPlayerInSession couldn't get the session interface!"));
bIsInSession = false;
return;
}
bIsInSession = SessionInterface->IsPlayerInSession(GameSessionName, *PlayerToCheck.GetUniqueNetId());
}
示例2: Tick
void APartyBeaconHost::Tick(float DeltaTime)
{
IOnlineSessionPtr SessionsInt = Online::GetSessionInterface();
if (SessionsInt.IsValid())
{
FNamedOnlineSession* Session = SessionsInt->GetNamedSession(SessionName);
if (Session)
{
TArray< TSharedPtr<FUniqueNetId> > PlayersToLogout;
for (int32 ResIdx=0; ResIdx < Reservations.Num(); ResIdx++)
{
FPartyReservation& PartyRes = Reservations[ResIdx];
// Determine if we have a client connection for the reservation
bool bIsConnectedReservation = false;
for (int32 ClientIdx=0; ClientIdx < ClientActors.Num(); ClientIdx++)
{
APartyBeaconClient* Client = Cast<APartyBeaconClient>(ClientActors[ClientIdx]);
if (Client)
{
const FPartyReservation& ClientRes = Client->GetPendingReservation();
if (ClientRes.PartyLeader == PartyRes.PartyLeader)
{
bIsConnectedReservation = true;
break;
}
}
else
{
UE_LOG(LogBeacon, Error, TEXT("Missing PartyBeaconClient found in ClientActors array"));
ClientActors.RemoveAtSwap(ClientIdx);
ClientIdx--;
}
}
// Don't update clients that are still connected
if (bIsConnectedReservation)
{
for (int32 PlayerIdx=0; PlayerIdx < PartyRes.PartyMembers.Num(); PlayerIdx++)
{
FPlayerReservation& PlayerEntry = PartyRes.PartyMembers[PlayerIdx];
PlayerEntry.ElapsedTime = 0.0f;
}
}
// Once a client disconnects, update the elapsed time since they were found as a registrant in the game session
else
{
for (int32 PlayerIdx=0; PlayerIdx < PartyRes.PartyMembers.Num(); PlayerIdx++)
{
FPlayerReservation& PlayerEntry = PartyRes.PartyMembers[PlayerIdx];
// Determine if the player is the owner of the session
const bool bIsSessionOwner = Session->OwningUserId.IsValid() && (*Session->OwningUserId == *PlayerEntry.UniqueId);
// Determine if the player member is registered in the game session
if (SessionsInt->IsPlayerInSession(SessionName, *PlayerEntry.UniqueId) ||
// Never timeout the session owner
bIsSessionOwner)
{
FUniqueNetIdMatcher PlayerMatch(*PlayerEntry.UniqueId);
int32 FoundIdx = PlayersPendingJoin.FindMatch(PlayerMatch);
if (FoundIdx != INDEX_NONE)
{
UE_LOG(LogBeacon, Display, TEXT("Beacon (%s): pending player %s found in session (%s)."),
*GetName(),
*PlayerEntry.UniqueId->ToDebugString(),
*SessionName.ToString());
// reset elapsed time since found
PlayerEntry.ElapsedTime = 0.0f;
// also remove from pending join list
PlayersPendingJoin.RemoveAtSwap(FoundIdx);
}
}
else
{
// update elapsed time
PlayerEntry.ElapsedTime += DeltaTime;
// if the player is pending it's initial join then check against TravelSessionTimeoutSecs instead
FUniqueNetIdMatcher PlayerMatch(*PlayerEntry.UniqueId);
int32 FoundIdx = PlayersPendingJoin.FindMatch(PlayerMatch);
const bool bIsPlayerPendingJoin = FoundIdx != INDEX_NONE;
// if the timeout has been exceeded then add to list of players
// that need to be logged out from the beacon
if ((bIsPlayerPendingJoin && PlayerEntry.ElapsedTime > TravelSessionTimeoutSecs) ||
(!bIsPlayerPendingJoin && PlayerEntry.ElapsedTime > SessionTimeoutSecs))
{
PlayersToLogout.AddUnique(PlayerEntry.UniqueId.GetUniqueNetId());
}
}
}
}
}
// Logout any players that timed out
for (int32 LogoutIdx=0; LogoutIdx < PlayersToLogout.Num(); LogoutIdx++)
{
bool bFound = false;
const TSharedPtr<FUniqueNetId>& UniqueId = PlayersToLogout[LogoutIdx];
//.........这里部分代码省略.........