5#include "OnlineSubsystem.h"
8#include "OnlineSubsystem.h"
9#include "OnlineSubsystemUtils.h"
10#include "OnlineAsyncTaskManager.h"
11#include "SocketSubsystem.h"
12#include "Interfaces/IPv4/IPv4Address.h"
13#include "JsonObjectConverter.h"
16#if ENGINE_MAJOR_VERSION >= 5
17#include "Online/OnlineBase.h"
18#include "Online/OnlineSessionNames.h"
22#define MAX_PUBLIC_CONNECTIONS 2048
26#define Log(pmt, ...) UE_LOG(LogPVROnlineSession, Log, TEXT(pmt), ##__VA_ARGS__)
27#define Warn(pmt, ...) UE_LOG(LogPVROnlineSession, Warning, TEXT(pmt), ##__VA_ARGS__)
28#define Error(pmt, ...) UE_LOG(LogPVROnlineSession, Error, TEXT(pmt), ##__VA_ARGS__)
29#define Fatal(pmt, ...) UE_LOG(LogPVROnlineSession, Fatal, TEXT(pmt), ##__VA_ARGS__)
33#if ENGINE_MAJOR_VERSION >= 5
34 SessionId(FUniqueNetIdPixoVR::Create(TEXT(
"INVALID")).Get())
36 SessionId(TEXT(
"INVALID"))
44 bool bCanBindAll=
false;
45 HostAddr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->GetLocalHostAddr(*GLog, bCanBindAll);
54 if ((HostIp & 0xff000000) == 0x7f000000)
60 HostAddr->SetPort(GetPortFromNetDriver(Subsystem.GetInstanceName()));
63 FPlatformMisc::CreateGuid(OwnerGuid);
65#if ENGINE_MAJOR_VERSION >= 5
66 SessionId = FUniqueNetIdPixoVR::Create(OwnerGuid.ToString()).Get();
68 SessionId = FUniqueNetIdPixoVR(OwnerGuid.ToString());
74 Subsystem(InSubsystem),
75 CurrentSessionSearch(nullptr),
76 SessionSearchStartTime(0),
77 SessionSearchEndTime(0)
92 TSharedPtr<FJsonObject> JsonMessageObject = MakeShareable(
new FJsonObject);
93 TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(*InJsonMessage);
95 if (!FJsonSerializer::Deserialize(Reader, JsonMessageObject))
97 Log(
"Failed to deserialize the websocket message.");
99 TriggerOnFindSessionsCompleteDelegates(
false);
103 Log(
"Successfully deserialized the websocket message.")
104 bool bHasError = JsonMessageObject->GetBoolField(
"error");
107 Log(
"Doesn't have an error. Checking to see if we found a match.");
108 FString Message = JsonMessageObject->GetStringField(
"message");
110 if (Message.Equals(
"match found", ESearchCase::IgnoreCase))
112 Log(
"Found a match!");
120 FString ErrorMessage = JsonMessageObject->GetStringField(
"message");
121 Log(
"Websocket error: %s", *ErrorMessage);
130 TSharedPtr<FJsonObject> MatchDetailsObject = JsonMessageObject->GetObjectField(
"matchDetails");
134 Error(
"The current search has been lost.");
135 TriggerOnFindSessionsCompleteDelegates(
false);
139 if (FJsonObjectConverter::JsonObjectToUStruct<FMatchDetails>(MatchDetailsObject.ToSharedRef(), &FoundMatchDetails))
141 Log(
"Parsed the match details.");
144 FOnlineSessionSearchResult* SearchResult =
new (
CurrentSessionSearch->SearchResults) FOnlineSessionSearchResult();
145 SearchResult->PingInMs = PingInMs;
146 FOnlineSession* NewSession = &SearchResult->Session;
149 SessionInfo->
HostAddr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
150#if ENGINE_MAJOR_VERSION >= 5
151 SessionInfo->
SessionId = FUniqueNetIdPixoVR::Create(FoundMatchDetails.
SessionID).Get();
155 int32 HostAddress = 0;
159 SessionInfo->
HostAddr->SetIp(HostAddress);
160 SessionInfo->
HostAddr->SetPort(HostPort);
161 NewSession->SessionSettings.Set(SETTING_MAPNAME, FoundMatchDetails.
MapName);
169 NewSession->SessionInfo = MakeShareable(SessionInfo);
171 TriggerOnFindSessionsCompleteDelegates(
true);
175 TriggerOnFindSessionsCompleteDelegates(
false);
220 if (Session ==
nullptr)
225 Session->SessionState = EOnlineSessionState::Creating;
226 Session->HostingPlayerNum = HostingPlayerNum;
231 if (Identity.IsValid())
233 Session->OwningUserId = Identity->GetUniquePlayerId(HostingPlayerNum);
234 Session->OwningUserName = Identity->GetPlayerNickname(HostingPlayerNum);
238 if (!Session->OwningUserId.IsValid())
240#if ENGINE_MAJOR_VERSION >= 5
241 Session->OwningUserId = FUniqueNetIdPixoVR::Create(FString::Printf(TEXT(
"%d"), HostingPlayerNum)).ToSharedPtr();
243 Session->OwningUserId = MakeShareable(
new FUniqueNetIdPixoVR(FString::Printf(TEXT(
"%d"), HostingPlayerNum)));
246 Session->OwningUserName = FString(TEXT(
"PVROUserName"));
250 Session->SessionSettings.BuildUniqueId = GetBuildUniqueId();
255 Session->SessionInfo = MakeShareable(NewSessionInfo);
258 if (NewSessionSettings.bIsLANMatch)
270 Session->SessionState = EOnlineSessionState::Pending;
285 Warn(
"Cannot create session '%s': session already exists.", *SessionName.ToString());
290 TriggerOnCreateSessionCompleteDelegates(SessionName, (Result ==
PVRO_SUCCESS) ?
true :
false);
306 bool bResult =
false;
307 for (int32 SessionIdx=0; SessionIdx <
Sessions.Num(); SessionIdx++)
309 FNamedOnlineSession& Session =
Sessions[SessionIdx];
322 return Session.SessionSettings.bShouldAdvertise &&
IsHost(Session) &&
325 !Session.SessionSettings.bIsLANMatch &&
326 (Session.SessionState != EOnlineSessionState::InProgress || (Session.SessionSettings.bAllowJoinInProgress && Session.NumOpenPublicConnections > 0))
330 Session.SessionSettings.bAllowJoinViaPresence || Session.SessionSettings.bAllowJoinViaPresenceFriendsOnly
337 const FOnlineSessionSettings& Settings = Session.SessionSettings;
340 const bool bIsAdvertised = Settings.bShouldAdvertise || Settings.bIsLANMatch;
341 const bool bIsMatchInProgress = Session.SessionState == EOnlineSessionState::InProgress;
343 const bool bJoinableFromProgress = (!bIsMatchInProgress || Settings.bAllowJoinInProgress);
345 const bool bAreSpacesAvailable = Session.NumOpenPublicConnections > 0;
349 return bIsAdvertised && bJoinableFromProgress && bAreSpacesAvailable;
354 uint32 Result = ONLINE_SUCCESS;
364 Result = ONLINE_FAIL;
389 Log(
"Starting session %s.", *SessionName.ToString());
396 if (Session->SessionState == EOnlineSessionState::Pending ||
397 Session->SessionState == EOnlineSessionState::Ended)
399 if (!Session->SessionSettings.bIsLANMatch)
402 Session->SessionState = EOnlineSessionState::InProgress;
407 if (!Session->SessionSettings.bAllowJoinInProgress)
412 Session->SessionState = EOnlineSessionState::InProgress;
417 Warn(
"Can't start an online session (%s) in state %s.", *SessionName.ToString(), EOnlineSessionState::ToString(Session->SessionState));
422 Warn(
"Can't start an online game for session (%s) that hasn't been created.", *SessionName.ToString());
428 TriggerOnStartSessionCompleteDelegates(SessionName, (Result ==
PVRO_SUCCESS) ?
true :
false);
436 bool bWasSuccessful =
true;
442 if (!Session->SessionSettings.bIsLANMatch)
448 Session->SessionSettings = UpdatedSessionSettings;
449 TriggerOnUpdateSessionCompleteDelegates(SessionName, bWasSuccessful);
453 return bWasSuccessful;
458 Warn(
"Ending session %s.", *SessionName.ToString());
467 if (Session->SessionState == EOnlineSessionState::InProgress)
469 if (!Session->SessionSettings.bIsLANMatch)
475 Session->SessionState = EOnlineSessionState::Ended;
483 Warn(
"Can't end session (%s) in state %s.", *SessionName.ToString(), EOnlineSessionState::ToString(Session->SessionState));
488 Warn(
"Can't end an online game for session (%s) that hasn't been created", *SessionName.ToString());
495 Session->SessionState = EOnlineSessionState::Ended;
498 TriggerOnEndSessionCompleteDelegates(SessionName, (Result ==
PVRO_SUCCESS) ?
true :
false);
516 if (Session->SessionState != EOnlineSessionState::Destroying)
518 if (Session->SessionState == EOnlineSessionState::InProgress)
530 CompletionDelegate.ExecuteIfBound(SessionName, (Result ==
PVRO_SUCCESS) ?
true :
false);
531 TriggerOnDestroySessionCompleteDelegates(SessionName, (Result ==
PVRO_SUCCESS) ?
true :
false);
536 Warn(
"Already in process of destroying session (%s).", *SessionName.ToString());
543 Warn(
"Can't destroy an online session that doesn't exist (%s).", *SessionName.ToString());
544 CompletionDelegate.ExecuteIfBound(SessionName,
false);
545 TriggerOnDestroySessionCompleteDelegates(SessionName,
false);
549 Error(
"There are no sessions to destroy.\nCheck against the Session Interface's Sessions before calling delete.\nWill not trigger OnDestroySession.");
558 Session->SessionState = EOnlineSessionState::Destroying;
559 if (Session->SessionInfo.IsValid())
564 if (VoiceInt.IsValid())
569 VoiceInt->UnregisterLocalTalkers();
573 VoiceInt->RemoveAllRemoteTalkers();
588 return IsPlayerInSessionImpl(
this, SessionName, UniqueId);
591bool FPVROnlineSession::StartMatchmaking(
const TArray< TSharedRef<const FUniqueNetId> >& LocalPlayers, FName SessionName,
const FOnlineSessionSettings& NewSessionSettings, TSharedRef<FOnlineSessionSearch>& SearchSettings)
593 Warn(
"StartMatchmaking is not supported on this platform. Use FindSessions or FindSessionById.");
594 TriggerOnMatchmakingCompleteDelegates(SessionName,
false);
600 Warn(
"CancelMatchmaking is not supported on this platform. Use CancelFindSessions.");
601 TriggerOnCancelMatchmakingCompleteDelegates(SessionName,
false);
607 Warn(
"CancelMatchmaking is not supported on this platform. Use CancelFindSessions.");
608 TriggerOnCancelMatchmakingCompleteDelegates(SessionName,
false);
619 if (!bIsValidCurrentSearch)
621 TriggerOnFindSessionsStartDelegates();
623 SearchSettings->SearchResults.Empty();
640 SearchSettings->SearchState = EOnlineAsyncTaskState::InProgress;
645 SearchSettings->SearchState = EOnlineAsyncTaskState::Failed;
650 Log(
"Ignoring game search request while one is pending");
662bool FPVROnlineSession::FindSessionById(
const FUniqueNetId& SearchingUserId,
const FUniqueNetId& SessionId,
const FUniqueNetId& FriendId,
const FOnSingleSessionResultCompleteDelegate& CompletionDelegates)
664 FOnlineSessionSearchResult EmptyResult;
665 CompletionDelegates.ExecuteIfBound(0,
false, EmptyResult);
673 int32 OrgId = -1, ModuleId = -1;
674 FString ModuleVersion, UserName;
675 SearchSettings->QuerySettings.Get<int32>(FName(TEXT(
"OrgID")), OrgId);
676 SearchSettings->QuerySettings.Get<int32>(FName(TEXT(
"ModuleID")), ModuleId);
677 SearchSettings->QuerySettings.Get<FString>(FName(TEXT(
"ModuleVersion")), ModuleVersion);
678 SearchSettings->QuerySettings.Get<FString>(FName(TEXT(
"UserName")), UserName);
699 Log(
"Clearing session search data.");
700 bool bCouldClear =
false;
711 Warn(
"No session search to clear.");
719 Log(
"Canceling session search.");
729 Warn(
"Can't cancel a search that isn't in progress");
734 TriggerOnCancelFindSessionsCompleteDelegates(
true);
743 FIPv4Address HostAddress;
744 bool Result = FIPv4Address::Parse(HostIP, HostAddress);
747 ISocketSubsystem* SocketSubsystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
750 FResolveInfo* ResolveInfo = SocketSubsystem->GetHostByName(TCHAR_TO_ANSI(*HostIP));
751 while (!ResolveInfo->IsComplete());
752 if (ResolveInfo->GetErrorCode() == 0)
754 const FInternetAddr* Address = &ResolveInfo->GetResolvedAddress();
757 Host = FIPv4Address(IP).Value;
763 Warn(
"FindSession: No SocketSubsystem found.");
768 Host = HostAddress.Value;
773 Port = FCString::Atoi(*HostPort);
778 Log(
"Attemping to join session %s.", *DesiredSession.GetSessionIdStr());
783 if (Session ==
nullptr)
785 TriggerOnJoinSessionStartDelegates();
789 if (VoiceInt.IsValid())
794 VoiceInt->UnregisterLocalTalkers();
798 VoiceInt->RemoveAllRemoteTalkers();
803 Session->HostingPlayerNum = PlayerNum;
807 Session->SessionInfo = MakeShareable(NewSessionInfo);
812 Session->SessionSettings.bShouldAdvertise =
false;
828 Warn(
"Session (%s) already exists, can't join twice.", *SessionName.ToString());
834 TriggerOnJoinSessionCompleteDelegates(SessionName, Return ==
PVRO_SUCCESS ? EOnJoinSessionCompleteResult::Success : EOnJoinSessionCompleteResult::UnknownError);
843 return JoinSession(0, SessionName, DesiredSession);
849 TArray<FOnlineSessionSearchResult> EmptySearchResult;
850 TriggerOnFindFriendSessionCompleteDelegates(LocalUserNum,
false, EmptySearchResult);
857 TArray<FOnlineSessionSearchResult> EmptySearchResult;
858 TriggerOnFindFriendSessionCompleteDelegates(0,
false, EmptySearchResult);
865 TArray<FOnlineSessionSearchResult> EmptySearchResult;
866 TriggerOnFindFriendSessionCompleteDelegates(0,
false, EmptySearchResult);
897 Session->SessionState = EOnlineSessionState::Pending;
899 if (Session->SessionInfo.IsValid() && SearchSession !=
nullptr && SearchSession->SessionInfo.IsValid())
907 SearchSessionInfo->
HostAddr->GetIp(IpAddr);
908 SessionInfo->
HostAddr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
909 SessionInfo->
HostAddr->SetIp(IpAddr);
926 bool bSuccess =
false;
927 if (SessionInfo.IsValid())
929 if (SessionInfo->HostAddr.IsValid() && SessionInfo->HostAddr->IsValid())
931 if (PortOverride != 0)
933 ConnectInfo = FString::Printf(TEXT(
"%s:%d"), *SessionInfo->HostAddr->ToString(
false), PortOverride);
937 ConnectInfo = FString::Printf(TEXT(
"%s"), *SessionInfo->HostAddr->ToString(
true));
949 bool bSuccess =
false;
952 if (Session !=
nullptr)
954 TSharedPtr<FPVROSessionInfo> SessionInfo = StaticCastSharedPtr<FPVROSessionInfo>(Session->SessionInfo);
955 if (PortType == NAME_BeaconPort)
957 int32 BeaconListenPort = GetBeaconPortFromSessionSettings(Session->SessionSettings);
960 else if (PortType == NAME_GamePort)
967 Warn(
"Invalid session info for session %s in GetResolvedConnectString()", *SessionName.ToString());
972 Warn(
"Unknown session name (%s) specified to GetResolvedConnectString().", *SessionName.ToString());
980 bool bSuccess =
false;
981 if (SearchResult.Session.SessionInfo.IsValid())
983 TSharedPtr<FPVROSessionInfo> SessionInfo = StaticCastSharedPtr<FPVROSessionInfo>(SearchResult.Session.SessionInfo);
985 if (PortType == NAME_BeaconPort)
987 int32 BeaconListenPort = GetBeaconPortFromSessionSettings(SearchResult.Session.SessionSettings);
991 else if (PortType == NAME_GamePort)
997 if (!bSuccess || ConnectInfo.IsEmpty())
999 Warn(
"Invalid session info in search result to GetResolvedConnectString().");
1010 return &Session->SessionSettings;
1020 if (VoiceInt.IsValid())
1022 for (int32 Index = 0; Index < MAX_LOCAL_PLAYERS; Index++)
1025 VoiceInt->RegisterLocalTalker(Index);
1036 if (VoiceInt.IsValid())
1038 if (!
Subsystem->IsLocalPlayer(PlayerId))
1040 VoiceInt->RegisterRemoteTalker(PlayerId);
1045 VoiceInt->ProcessMuteChangeNotification();
1056 if (VoiceInt.IsValid())
1058 if (!
Subsystem->IsLocalPlayer(PlayerId))
1060 if (VoiceInt.IsValid())
1062 VoiceInt->UnregisterRemoteTalker(PlayerId);
1071#if ENGINE_MAJOR_VERSION >= 5
1072 TArray<FUniqueNetIdRef> Players;
1073 Players.Add(FUniqueNetIdPixoVR::Create(PlayerId));
1075 TArray<TSharedRef<const FUniqueNetId>> Players;
1076 Players.Add(MakeShareable(
new FUniqueNetIdPixoVR(PlayerId)));
1083 bool bSuccess =
false;
1089 for (int32 PlayerIdx=0; PlayerIdx<Players.Num(); PlayerIdx++)
1091 const TSharedRef<const FUniqueNetId>& PlayerId = Players[PlayerIdx];
1093 FUniqueNetIdMatcher PlayerMatch(*PlayerId);
1094 if (Session->RegisteredPlayers.IndexOfByPredicate(PlayerMatch) == INDEX_NONE)
1096 Session->RegisteredPlayers.Add(PlayerId);
1102 Log(
"Player %s already registered in session %s.", *PlayerId->ToDebugString(), *SessionName.ToString());
1108 Warn(
"No game present to join for session (%s).", *SessionName.ToString());
1111 TriggerOnRegisterPlayersCompleteDelegates(SessionName, Players, bSuccess);
1117#if ENGINE_MAJOR_VERSION >= 5
1118 TArray<FUniqueNetIdRef> Players;
1119 Players.Add(FUniqueNetIdPixoVR::Create(PlayerId));
1121 TArray<TSharedRef<const FUniqueNetId>> Players;
1122 Players.Add(MakeShareable(
new FUniqueNetIdPixoVR(PlayerId)));
1129 bool bSuccess =
true;
1134 for (int32 PlayerIdx=0; PlayerIdx < Players.Num(); PlayerIdx++)
1136 const TSharedRef<const FUniqueNetId>& PlayerId = Players[PlayerIdx];
1138 FUniqueNetIdMatcher PlayerMatch(*PlayerId);
1139 int32 RegistrantIndex = Session->RegisteredPlayers.IndexOfByPredicate(PlayerMatch);
1140 if (RegistrantIndex != INDEX_NONE)
1142 Session->RegisteredPlayers.RemoveAtSwap(RegistrantIndex);
1147 Warn(
"Player %s is not part of session (%s).", *PlayerId->ToDebugString(), *SessionName.ToString());
1153 Warn(
"No game present to leave for session (%s).", *SessionName.ToString());
1157 TriggerOnUnregisterPlayersCompleteDelegates(SessionName, Players, bSuccess);
1163 SCOPE_CYCLE_COUNTER(STAT_Session_Interface);
1168 float CurrentTimeInSeconds = FPlatformTime::Seconds();
1184 Log(
"Executing OnValidQueryPacketReceived.");
1188 for (int32 SessionIndex = 0; SessionIndex <
Sessions.Num(); SessionIndex++)
1190 Warn(
"OnValidQueryPacketReceived Session is Registered.");
1192 FNamedOnlineSession* Session = &
Sessions[SessionIndex];
1197 Warn(
"Session valid trough Session Index.");
1199 const FOnlineSessionSettings& Settings = Session->SessionSettings;
1201 const bool bIsMatchInProgress = Session->SessionState == EOnlineSessionState::InProgress;
1203 const bool bIsMatchJoinable = (!bIsMatchInProgress || Settings.bAllowJoinInProgress) && Settings.NumPublicConnections > 0;
1204 if (bIsMatchJoinable)
1206 Warn(
"Match from query is joinable.");
1216 FOnlineSessionSettings NewServer;
1220 FOnlineSessionSearchResult* NewResult =
new (
CurrentSessionSearch->SearchResults) FOnlineSessionSearchResult();
1224 FOnlineSession* NewSession = &NewResult->Session;
1228 Warn(
"Failed to create new online game settings object.");
1259 TriggerOnFindSessionsCompleteDelegates(
true);
1272 for (int32 SessionIdx=0; SessionIdx <
Sessions.Num(); SessionIdx++)
1274 DumpNamedSession(&
Sessions[SessionIdx]);
1280 Delegate.ExecuteIfBound(PlayerId, EOnJoinSessionCompleteResult::Success);
1285 Delegate.ExecuteIfBound(PlayerId,
true);
1290 auto NetDriverPort = GetPortFromNetDriver(
Subsystem.GetInstanceName());
1291 auto SessionInfoPixoVR = StaticCastSharedPtr<FPVROSessionInfo>(SessionInfo);
1292 if (SessionInfoPixoVR.IsValid() && SessionInfoPixoVR->HostAddr.IsValid())
1294 SessionInfoPixoVR->HostAddr->SetPort(NetDriverPort);
1305#if ENGINE_MAJOR_VERSION >= 5
1306 FUniqueNetIdPixoVRRef UserId = FUniqueNetIdPixoVR::Create(FString::Printf(TEXT(
"%d"), Session.HostingPlayerNum));
1307 return (UserId->IsValid() && (*UserId == *Session.OwningUserId));
1309 TSharedPtr<const FUniqueNetId> UserId = MakeShareable(
new FUniqueNetIdPixoVR(FString::Printf(TEXT(
"%d"), Session.HostingPlayerNum)));
1310 return (UserId.IsValid() && (*UserId == *Session.OwningUserId));
1316#if ENGINE_MAJOR_VERSION >= 5
1318 if (!SessionIdStr.IsEmpty())
1320 SessionId = FUniqueNetIdPixoVR::Create(SessionIdStr);
1324 if (!SessionIdStr.IsEmpty())
1326 SessionId = MakeShared<FUniqueNetIdPixoVR>(SessionIdStr);
1335 FString ServerName = TEXT(
"");
1336 if(FParse::Value(FCommandLine::Get(), TEXT(
"-PIXOVR_SERVER_NAME="), ServerName))
FOnPortChanged::FDelegate FOnPortChangedDelegate
FOnValidQueryPacket::FDelegate FOnValidQueryPacketDelegate
TSharedPtr< const FUniqueNetId > FUniqueNetIdPtr
static bool GetConnectStringFromSessionInfo(TSharedPtr< FPVROSessionInfo > &SessionInfo, FString &ConnectInfo, int32 PortOverride=0)
#define MAX_PUBLIC_CONNECTIONS
DEFINE_LOG_CATEGORY_STATIC(LogPVROnlineSession, Log, All)
void Tick(float DeltaTime)
ELanBeaconState::Type GetBeaconState() const
bool Host(FOnValidQueryPacketDelegate &QueryDelegate, int32 Port=-1)
TSharedPtr< class FInternetAddr > HostAddr
FUniqueNetIdPixoVR SessionId
void Init(const FPVROSubsystem &Subsystem)
bool FindSessions(int InOrgId=-1, int InModuleId=-1, FString InUserName="", FString InModuleVersion="")
MultiplayerWebSocket WebSocket
virtual IOnlineIdentityPtr GetIdentityInterface() const override
virtual IOnlineVoicePtr GetVoiceInterface() const override
virtual bool PingSearchResults(const FOnlineSessionSearchResult &SearchResult) override
FString GetCustomDedicatedServerName() const
Returns the custom server name if specified as argument.
uint32 CreateInternetSession(int32 HostingPlayerNum, FNamedOnlineSession *Session)
void OnLANSearchTimeout()
uint32 CreateLANSession(int32 HostingPlayerNum, FNamedOnlineSession *Session)
virtual bool UnregisterPlayers(FName SessionName, const TArray< TSharedRef< const FUniqueNetId > > &Players) override
virtual bool EndSession(FName SessionName) override
virtual bool JoinSession(int32 PlayerNum, FName SessionName, const FOnlineSessionSearchResult &DesiredSession) override
virtual bool RegisterPlayers(FName SessionName, const TArray< TSharedRef< const FUniqueNetId > > &Players, bool bWasInvited=false) override
void GetHostAndPort(int32 &Host, int32 &Port, const FString &HostIP, const FString &HostPort)
void CheckMatchesFound(TSharedPtr< FJsonObject > &JsonMessageObject)
void OnSessionListenPortChanged(int32 Port)
void Tick(float DeltaTime)
void OnValidQueryPacketReceived(uint8 *PacketData, int32 PacketLength, uint64 ClientNonce)
uint32 DestroyLANSession(FName SessionName, const FOnDestroySessionCompleteDelegate &CompletionDelegate=FOnDestroySessionCompleteDelegate())
FNamedOnlineSession * GetNamedSession(FName SessionName) override
void HandleMessageReceived(const FString &InJsonMessage)
virtual bool FindSessions(int32 SearchingPlayerNum, const TSharedRef< FOnlineSessionSearch > &SearchSettings) override
virtual bool CancelFindSessions() override
TSharedPtr< FOnlineSessionSearch > CurrentSessionSearch
virtual TSharedPtr< const FUniqueNetId > CreateSessionIdFromString(const FString &SessionIdStr) override
bool ClearSessionSearch(EOnlineAsyncTaskState::Type TaskState=EOnlineAsyncTaskState::Done)
virtual bool IsPlayerInSession(FName SessionName, const FUniqueNetId &UniqueId) override
uint32 FindInternetSession(const TSharedRef< FOnlineSessionSearch > &SearchSettings)
static void SetPortFromNetDriver(const FPVROSubsystem &Subsystem, const TSharedPtr< FOnlineSessionInfo > &SessionInfo)
uint32 EndInternetSession(FNamedOnlineSession *Session)
uint32 JoinInternetSession(int32 PlayerNum, class FNamedOnlineSession *Session, const class FOnlineSession *SearchSession)
virtual bool FindFriendSession(int32 LocalUserNum, const FUniqueNetId &Friend) override
void OnValidResponsePacketReceived(uint8 *PacketData, int32 PacketLength)
virtual bool StartSession(FName SessionName) override
double SessionSearchStartTime
class FNamedOnlineSession * AddNamedSession(FName SessionName, const FOnlineSessionSettings &SessionSettings) override
virtual bool DestroySession(FName SessionName, const FOnDestroySessionCompleteDelegate &CompletionDelegate=FOnDestroySessionCompleteDelegate()) override
virtual bool RegisterPlayer(FName SessionName, const FUniqueNetId &PlayerId, bool bWasInvited) override
virtual void RegisterLocalPlayer(const FUniqueNetId &PlayerId, FName SessionName, const FOnRegisterLocalPlayerCompleteDelegate &Delegate) override
virtual void RemoveNamedSession(FName SessionName) override
virtual FOnlineSessionSettings * GetSessionSettings(FName SessionName) override
void RegisterVoice(const FUniqueNetId &PlayerId)
FCriticalSection SessionLock
virtual bool GetResolvedConnectString(FName SessionName, FString &ConnectInfo, FName PortType) override
void UnregisterVoice(const FUniqueNetId &PlayerId)
virtual bool CreateSession(int32 HostingPlayerNum, FName SessionName, const FOnlineSessionSettings &NewSessionSettings) override
virtual bool FindSessionById(const FUniqueNetId &SearchingUserId, const FUniqueNetId &SessionId, const FUniqueNetId &FriendId, const FOnSingleSessionResultCompleteDelegate &CompletionDelegate) override
uint32 DestroyInternetSession(FNamedOnlineSession *Session, const FOnDestroySessionCompleteDelegate &CompletionDelegate=FOnDestroySessionCompleteDelegate())
bool IsHost(const FNamedOnlineSession &Session) const
virtual int32 GetNumSessions() override
double SessionSearchEndTime
virtual void UnregisterLocalPlayer(const FUniqueNetId &PlayerId, FName SessionName, const FOnUnregisterLocalPlayerCompleteDelegate &Delegate) override
virtual bool SendSessionInviteToFriend(int32 LocalUserNum, FName SessionName, const FUniqueNetId &Friend) override
virtual bool StartMatchmaking(const TArray< TSharedRef< const FUniqueNetId > > &LocalPlayers, FName SessionName, const FOnlineSessionSettings &NewSessionSettings, TSharedRef< FOnlineSessionSearch > &SearchSettings) override
TArray< FNamedOnlineSession > Sessions
virtual bool UnregisterPlayer(FName SessionName, const FUniqueNetId &PlayerId) override
virtual bool CancelMatchmaking(int32 SearchingPlayerNum, FName SessionName) override
FPVROSession LANSessionManager
void TickLanTasks(float DeltaTime)
virtual bool SendSessionInviteToFriends(int32 LocalUserNum, FName SessionName, const TArray< TSharedRef< const FUniqueNetId > > &Friends) override
uint32 FindLANSession(const TSharedRef< FOnlineSessionSearch > &SearchSettings)
bool IsSessionJoinable(const FNamedOnlineSession &Session) const
virtual void DumpSessionState() override
virtual bool UpdateSession(FName SessionName, FOnlineSessionSettings &UpdatedSessionSettings, bool bShouldRefreshOnlineData=true) override
uint32 FinalizeLANSearch()
void RegisterLocalPlayers(class FNamedOnlineSession *Session)
class FPVROSubsystem * Subsystem
FSocketMessageReceived & OnWebSocketMessageReceived()
FSocketDisconnected & OnWebSocketDisconnected()
FSocketConnectFailed & OnWebSocketConnectFailed()
FString OwningUserName
UPROPERTY()
FString MapName
UPROPERTY()
FString SessionID
UPROPERTY()
FString IPAddress
UPROPERTY()