10#include "Containers/Ticker.h"
12#include "Delegates/Delegate.h"
13#include "Engine/EngineBaseTypes.h"
14#include "Misc/Optional.h"
15#include "Subsystems/GameInstanceSubsystem.h"
16#include "Templates/UniquePtr.h"
17#include "UObject/WeakObjectPtr.h"
19#include "SessionTransitionSubsystem.generated.h"
25class FGameplayRuntimeInternalAccessKey;
182 const Nelaric::FStartTransitionApproval& Source,
183 const Nelaric::FStartTransitionApproval& Target,
184 const Nelaric::FOnTransitionTerminated& Terminated);
197 uint64 RequestId,
bool bApproved);
205 uint64 RequestId,
bool bApproved);
216 GAMEPLAYRUNTIME_API
virtual void Initialize(FSubsystemCollectionBase& Collection)
override;
222 struct FActiveTransition
227 TWeakObjectPtr<UWorld> SourceWorld;
228 double DeadlineSeconds = 0.0;
229 bool bSourceApproved =
false;
230 bool bTargetApproved =
false;
231 bool bTravelStarted =
false;
234 bool Tick(
float DeltaTime);
235 void TryStartTravel();
237 void FinishSucceeded(ENetMode Mode);
238 void FinishTimedOut();
239 void FinishCancelled();
241 Nelaric::FStartTransitionApproval StartSourceApproval;
242 Nelaric::FStartTransitionApproval StartTargetApproval;
243 Nelaric::FOnTransitionTerminated OnTerminated;
244 TUniquePtr<FActiveTransition> Active;
245 FTSTicker::FDelegateHandle TickHandle;
246 uint64 NextRequestId = 1;
DECLARE_DELEGATE_TwoParams(FOnTransitionSucceeded, FTransitionHandle, ENetMode)
Reports a verified destination mode on the game thread.
DECLARE_DELEGATE_RetVal_TwoParams(bool, FStartTransitionApproval, uint64, const FTransitionDestination &)
Starts approval for a request and its destination endpoints.
ETransitionError
Reason a network-mode request could not complete.
Definition SessionTransitionSubsystem.h:57
@ MissingDestination
A required map or remote destination is unavailable.
Definition SessionTransitionSubsystem.h:65
@ NoWorld
No game world is available for the request.
Definition SessionTransitionSubsystem.h:62
@ AuthorityRejected
The source or destination authority denied the request.
Definition SessionTransitionSubsystem.h:71
@ UnsupportedMode
The target mode or source-to-target route is unsupported.
Definition SessionTransitionSubsystem.h:59
@ ConfirmationInvalid
A confirmation expired or no longer matches this request.
Definition SessionTransitionSubsystem.h:77
@ NetworkFailed
Network setup or connection failed.
Definition SessionTransitionSubsystem.h:83
@ TravelFailed
Map travel did not establish the requested world.
Definition SessionTransitionSubsystem.h:80
@ UnexpectedNetMode
The resulting world has a different network mode.
Definition SessionTransitionSubsystem.h:86
@ Busy
Another transition is already active.
Definition SessionTransitionSubsystem.h:68
@ AuthorityUnavailable
A required authority could not be reached for confirmation.
Definition SessionTransitionSubsystem.h:74
DECLARE_DELEGATE_OneParam(FOnTransitionTerminated, uint64)
Releases transport state for a terminal request.
Coordinates requests for a game world's network role.
Definition SessionTransitionSubsystem.h:131
GAMEPLAYRUNTIME_API void InternalClearApprovalTransport(const Nelaric::FGameplayRuntimeInternalAccessKey &Key)
Removes the internal approval transport on the game thread.
GAMEPLAYRUNTIME_API TOptional< ENetMode > GetNetMode() const
Reads the current game world's observed network mode.
GAMEPLAYRUNTIME_API bool CancelTransition(Nelaric::FTransitionHandle Handle)
Requests cancellation of an active transition.
GAMEPLAYRUNTIME_API void InternalConfigureApprovalTransport(const Nelaric::FGameplayRuntimeInternalAccessKey &Key, const Nelaric::FStartTransitionApproval &Source, const Nelaric::FStartTransitionApproval &Target, const Nelaric::FOnTransitionTerminated &Terminated)
Binds the internal approval transport on the game thread.
GAMEPLAYRUNTIME_API void InternalReportTargetApproval(const Nelaric::FGameplayRuntimeInternalAccessKey &Key, uint64 RequestId, bool bApproved)
Reports the target authority's decision.
GAMEPLAYRUNTIME_API void InternalReportTargetUnavailable(const Nelaric::FGameplayRuntimeInternalAccessKey &Key, uint64 RequestId)
Reports that the target authority could not be reached.
virtual GAMEPLAYRUNTIME_API void Deinitialize() override
Ends active work before the game instance subsystem is destroyed.
GAMEPLAYRUNTIME_API void InternalReportSourceApproval(const Nelaric::FGameplayRuntimeInternalAccessKey &Key, uint64 RequestId, bool bApproved)
Reports the source authority's decision.
virtual GAMEPLAYRUNTIME_API void Initialize(FSubsystemCollectionBase &Collection) override
Registers the coordinator's tick while its game instance lives.
GAMEPLAYRUNTIME_API Nelaric::FTransitionHandle RequestTransition(ENetMode TargetMode, const Nelaric::FTransitionDestination &Destination, const Nelaric::FTransitionCallbacks &Callbacks)
Requests a move from one remote server to another.
Host address and transport port of one network endpoint.
Definition NetworkEndpoint.h:20
Terminal callbacks for one asynchronous mode request.
Definition SessionTransitionSubsystem.h:107
FOnTransitionSucceeded OnSucceeded
Called after the destination connection passes verification.
Definition SessionTransitionSubsystem.h:109
FOnTransitionFailed OnFailed
Called when the request cannot complete.
Definition SessionTransitionSubsystem.h:118
FOnTransitionTimedOut OnTimedOut
Called when the request exceeds its bounded timeout.
Definition SessionTransitionSubsystem.h:115
FOnTransitionCancelled OnCancelled
Called when the request is cancelled before completion.
Definition SessionTransitionSubsystem.h:112
Game and approval endpoints of one destination server.
Definition SessionTransitionSubsystem.h:34
FNetworkEndpoint BeaconEndpoint
Destination approval beacon address and port.
Definition SessionTransitionSubsystem.h:39
FNetworkEndpoint GameEndpoint
Destination game server address and port.
Definition SessionTransitionSubsystem.h:36
Stable identity of one accepted transition request.
Definition SessionTransitionSubsystem.h:50
uint64 Id
Zero is not an active request identity.
Definition SessionTransitionSubsystem.h:52