5#include "CoreMinimal.h"
6#if ENGINE_MAJOR_VERSION >= 5
7#include "Online/CoreOnline.h"
9#include "UObject/CoreOnline.h"
11#include "Misc/ScopeLock.h"
12#include "OnlineSessionSettings.h"
13#include "OnlineDelegateMacros.h"
14#include "Interfaces/OnlineSessionInterface.h"
93 uint32
JoinInternetSession(int32 PlayerNum,
class FNamedOnlineSession* Session,
const class FOnlineSession* SearchSession);
107 uint32
FindLANSession(
const TSharedRef<FOnlineSessionSearch>& SearchSettings);
146 bool IsHost(
const FNamedOnlineSession& Session)
const;
167 void Tick(
float DeltaTime);
173 void GetHostAndPort(int32& Host, int32& Port,
const FString& HostIP,
const FString& HostPort);
176 class FNamedOnlineSession*
AddNamedSession(FName SessionName,
const FOnlineSessionSettings& SessionSettings)
override
179 return new (
Sessions) FNamedOnlineSession(SessionName, SessionSettings);
182 class FNamedOnlineSession*
AddNamedSession(FName SessionName,
const FOnlineSession& Session)
override
185 return new (
Sessions) FNamedOnlineSession(SessionName, Session);
228 bool ClearSessionSearch(EOnlineAsyncTaskState::Type TaskState = EOnlineAsyncTaskState::Done);
252 for (int32 SearchIndex = 0; SearchIndex <
Sessions.Num(); SearchIndex++)
254 if (
Sessions[SearchIndex].SessionName == SessionName)
265 for (int32 SearchIndex = 0; SearchIndex <
Sessions.Num(); SearchIndex++)
267 if (
Sessions[SearchIndex].SessionName == SessionName)
278 for (int32 SearchIndex = 0; SearchIndex <
Sessions.Num(); SearchIndex++)
280 if (
Sessions[SearchIndex].SessionName == SessionName)
282 return Sessions[SearchIndex].SessionState;
286 return EOnlineSessionState::NoSession;
292 for (int32 SearchIndex = 0; SearchIndex <
Sessions.Num(); SearchIndex++)
294 if (
Sessions[SearchIndex].SessionSettings.bUsesPresence)
304 uint32
CreateLANSession(int32 HostingPlayerNum, FNamedOnlineSession* Session);
305 uint32
DestroyInternetSession(FNamedOnlineSession* Session,
const FOnDestroySessionCompleteDelegate& CompletionDelegate = FOnDestroySessionCompleteDelegate());
306 uint32
DestroyLANSession(FName SessionName,
const FOnDestroySessionCompleteDelegate& CompletionDelegate = FOnDestroySessionCompleteDelegate());
310 virtual bool CreateSession(int32 HostingPlayerNum, FName SessionName,
const FOnlineSessionSettings& NewSessionSettings)
override;
311 virtual bool CreateSession(
const FUniqueNetId& HostingPlayerId, FName SessionName,
const FOnlineSessionSettings& NewSessionSettings)
override;
313 virtual bool UpdateSession(FName SessionName, FOnlineSessionSettings& UpdatedSessionSettings,
bool bShouldRefreshOnlineData =
true)
override;
314 virtual bool EndSession(FName SessionName)
override;
315 virtual bool DestroySession(FName SessionName,
const FOnDestroySessionCompleteDelegate& CompletionDelegate = FOnDestroySessionCompleteDelegate())
override;
316 virtual bool IsPlayerInSession(FName SessionName,
const FUniqueNetId& UniqueId)
override;
317 virtual bool StartMatchmaking(
const TArray< TSharedRef<const FUniqueNetId> >& LocalPlayers, FName SessionName,
const FOnlineSessionSettings& NewSessionSettings, TSharedRef<FOnlineSessionSearch>& SearchSettings)
override;
318 virtual bool CancelMatchmaking(int32 SearchingPlayerNum, FName SessionName)
override;
319 virtual bool CancelMatchmaking(
const FUniqueNetId& SearchingPlayerId, FName SessionName)
override;
320 virtual bool FindSessions(int32 SearchingPlayerNum,
const TSharedRef<FOnlineSessionSearch>& SearchSettings)
override;
321 virtual bool FindSessions(
const FUniqueNetId& SearchingPlayerId,
const TSharedRef<FOnlineSessionSearch>& SearchSettings)
override;
322 virtual bool FindSessionById(
const FUniqueNetId& SearchingUserId,
const FUniqueNetId& SessionId,
const FUniqueNetId& FriendId,
const FOnSingleSessionResultCompleteDelegate& CompletionDelegate)
override;
324 virtual bool PingSearchResults(
const FOnlineSessionSearchResult& SearchResult)
override;
325 virtual bool JoinSession(int32 PlayerNum, FName SessionName,
const FOnlineSessionSearchResult& DesiredSession)
override;
326 virtual bool JoinSession(
const FUniqueNetId& PlayerId, FName SessionName,
const FOnlineSessionSearchResult& DesiredSession)
override;
327 virtual bool FindFriendSession(int32 LocalUserNum,
const FUniqueNetId& Friend)
override;
328 virtual bool FindFriendSession(
const FUniqueNetId& LocalUserId,
const FUniqueNetId& Friend)
override;
329 virtual bool FindFriendSession(
const FUniqueNetId& LocalUserId,
const TArray<TSharedRef<const FUniqueNetId>>& FriendList)
override;
331 virtual bool SendSessionInviteToFriend(
const FUniqueNetId& LocalUserId, FName SessionName,
const FUniqueNetId& Friend)
override;
332 virtual bool SendSessionInviteToFriends(int32 LocalUserNum, FName SessionName,
const TArray< TSharedRef<const FUniqueNetId> >& Friends)
override;
333 virtual bool SendSessionInviteToFriends(
const FUniqueNetId& LocalUserId, FName SessionName,
const TArray< TSharedRef<const FUniqueNetId> >& Friends)
override;
335 virtual bool GetResolvedConnectString(
const FOnlineSessionSearchResult& SearchResult, FName PortType, FString& ConnectInfo)
override;
337 virtual bool RegisterPlayer(FName SessionName,
const FUniqueNetId& PlayerId,
bool bWasInvited)
override;
338 virtual bool RegisterPlayers(FName SessionName,
const TArray< TSharedRef<const FUniqueNetId> >& Players,
bool bWasInvited =
false)
override;
339 virtual bool UnregisterPlayer(FName SessionName,
const FUniqueNetId& PlayerId)
override;
340 virtual bool UnregisterPlayers(FName SessionName,
const TArray< TSharedRef<const FUniqueNetId> >& Players)
override;
341 virtual void RegisterLocalPlayer(
const FUniqueNetId& PlayerId, FName SessionName,
const FOnRegisterLocalPlayerCompleteDelegate& Delegate)
override;
342 virtual void UnregisterLocalPlayer(
const FUniqueNetId& PlayerId, FName SessionName,
const FOnUnregisterLocalPlayerCompleteDelegate& Delegate)
override;
FOnFindSessionsStart::FDelegate FOnFindSessionsStartDelegate
TSharedPtr< FPVROnlineSession, ESPMode::ThreadSafe > FPVROnlineSessionPtr
FOnJoinSessionStart::FDelegate FOnJoinSessionStartDelegate
DECLARE_MULTICAST_DELEGATE(FOnFindSessionsStart)
virtual bool HasPresenceSession() 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)
FNamedOnlineSession * GetFirstNamedSession()
class FNamedOnlineSession * AddNamedSession(FName SessionName, const FOnlineSession &Session) override
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)
DEFINE_ONLINE_DELEGATE(OnJoinSessionStart)
uint32 DestroyLANSession(FName SessionName, const FOnDestroySessionCompleteDelegate &CompletionDelegate=FOnDestroySessionCompleteDelegate())
FNamedOnlineSession * GetNamedSession(FName SessionName) override
void HandleMessageReceived(const FString &InJsonMessage)
DEFINE_ONLINE_DELEGATE(OnFindSessionsStart)
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)
void CheckPendingSessionInvite()
virtual bool IsPlayerInSession(FName SessionName, const FUniqueNetId &UniqueId) override
TSharedPtr< FUniqueNetIdPixoVR > GameServerPixoVRId
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
void UnregisterLocalPlayers(class FNamedOnlineSession *Session)
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
virtual ~FPVROnlineSession()
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)
virtual EOnlineSessionState::Type GetSessionState(FName SessionName) const override
class FPVROSubsystem * Subsystem