SessionTimeoutSecs

SessionTimeoutSecs

#Overview

name: SessionTimeoutSecs

The value of this variable can be defined or overridden in .ini config files. 2 .ini config files referencing this setting variable.

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of SessionTimeoutSecs is to define the maximum duration, in seconds, that a player’s reservation can remain active without being registered with the game session before it is automatically removed.

This setting variable is primarily used by the Online Subsystem Utils plugin in Unreal Engine 5, specifically within the Party Beacon and Spectator Beacon systems. These systems are part of the networking and multiplayer functionality of the engine.

The value of this variable is set through configuration files, as indicated by the UPROPERTY(Transient, Config) decorator in the class declarations of APartyBeaconHost and ASpectatorBeaconHost.

SessionTimeoutSecs interacts closely with another variable called TravelSessionTimeoutSecs, which serves a similar purpose but is specifically used during level transitions or server travel.

Developers must be aware that this variable directly affects the behavior of multiplayer sessions, particularly in scenarios where players are joining or maintaining their connection to a game. If set too low, it might cause premature disconnections; if set too high, it could lead to unnecessary resource allocation for inactive players.

Best practices when using this variable include:

  1. Carefully tuning the value based on your game’s specific needs and network conditions.
  2. Considering different timeout values for various network scenarios (e.g., initial connection vs. maintaining connection during gameplay).
  3. Implementing proper error handling and user feedback mechanisms for timeout-related disconnections.
  4. Regularly testing with various network conditions to ensure the timeout value is appropriate.
  5. Documenting the chosen value and the rationale behind it for future reference and potential adjustments.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:2390, section: [/Script/OnlineSubsystemUtils.PartyBeaconHost]

Location: <Workspace>/Engine/Config/BaseEngine.ini:2395, section: [/Script/OnlineSubsystemUtils.SpectatorBeaconHost]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/PartyBeaconHost.cpp:485

Scope (from outer to inner):

file
function     float APartyBeaconHost::GetSessionTimeoutSecs

Source code excerpt:

float APartyBeaconHost::GetSessionTimeoutSecs(const FUniqueNetIdRepl& PlayerId) const
{
	return SessionTimeoutSecs;
}

bool APartyBeaconHost::GetPartyLeader(const FUniqueNetIdRepl& InPartyMemberId, FUniqueNetIdRepl& OutPartyLeaderId) const
{
	bool bHasLeader = false;
	if (State)

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Private/SpectatorBeaconHost.cpp:150

Scope: file

Source code excerpt:

								// that need to be logged out from the beacon
								if ((bIsPlayerPendingJoin && PlayerEntry.ElapsedTime > TravelSessionTimeoutSecs) ||
									(!bIsPlayerPendingJoin && PlayerEntry.ElapsedTime > SessionTimeoutSecs))
								{
									PlayersToLogout.AddUnique(PlayerEntry.UniqueId.GetUniqueNetId());
								}
							}
						}
					}

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Public/PartyBeaconHost.h:428

Scope (from outer to inner):

file
class        class APartyBeaconHost : public AOnlineBeaconHostObject

Source code excerpt:

	/** Seconds that can elapse before a reservation is removed due to player not being registered with the session */
	UPROPERTY(Transient, Config)
	float SessionTimeoutSecs;
	/** Seconds that can elapse before a reservation is removed due to player not being registered with the session during a travel */
	UPROPERTY(Transient, Config)
	float TravelSessionTimeoutSecs;

	/**
	 * @return the class of the state object inside this beacon

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemUtils/Source/OnlineSubsystemUtils/Public/SpectatorBeaconHost.h:245

Scope (from outer to inner):

file
class        class ASpectatorBeaconHost : public AOnlineBeaconHostObject

Source code excerpt:

	/** Seconds that can elapse before a reservation is removed due to player not being registered with the session */
	UPROPERTY(Transient, Config)
		float SessionTimeoutSecs;
	/** Seconds that can elapse before a reservation is removed due to player not being registered with the session during a travel */
	UPROPERTY(Transient, Config)
		float TravelSessionTimeoutSecs;

	/**
	* @return the class of the state object inside this beacon