class

FNetSession

The session surface a co-op game actually calls. Owns the host/join/leave state machine on top of NetworkManager + ReplicationManager, one player record per connection (pawn spawned on join, destroyed on leave), and a gameplay-event channel that rides the existing RPC packet with a default-deny client->server policy.

Module
Networking
Header
#include "Networking/Session/FNetSession.h"
Namespace
Mowo

Ticked from ReplicationManager::Update, which Scene drives in the runtime and simulation system sets. Headless drivers call Tick directly.

Type aliases

AliasDescription
using FPawnHostFactoryFn = INetPawnHost* (*)(MWorld* world)Factory invoked whenever a session gains an actor world (host/join/ world-swap with an MWorld); release is called with the same pointer on leave/swap so allocation and free stay in the installing image.
using FPawnHostReleaseFn = void (*)(INetPawnHost* host)
using FContentIdentityFn = void (*)(std::string& outBuildId, uint64_t& outContentHash)Build id + mounted-content hash for the join compatibility handshake (DLC lives above this module). Unset provider = empty id + 0, which still round-trips the handshake symmetrically.
using FWorldAdapterFn = World* (*)(MWorld* world)MWorld is opaque down here; the same installer provides the one thing the convenience overloads need from it — its ECS world.
using EventHandler = std::function<void(uint32_t senderPlayerId, FNetEventReader& reader)>
using PlayerDelegate = std::function<void(const FNetPlayer&)>
using StateDelegate = std::function<void(ENetSessionState, ENetSessionFailure)>
using LidarShotDelegate = std::function<void(const FNetLidarShot&)>
using RpcFallback = std::function<void(NetworkId, uint16_t, uint16_t, const uint8_t*, size_t, uint32_t)>
using TravelDelegate = std::function<void(const std::string& scenePath, uint32_t travelId)>
using FActorRpcInvokeFn = void (*)(uint64_t entityId, AActor* actorOrNull, const uint8_t* data, size_t len, bool fromServer, uint32_t senderPeerId)Game-installed receive dispatch. Plain fn ptr — it crosses a DLL boundary; the session treats AActor* as opaque and hands over both the resolved entity and the attach-registry actor (null when the entity was never registered — the installer may resolve it through its own world).
using PhaseDelegate = std::function<void(ENetSessionPhase)>
using ReturnToMenuDelegate = std::function<void(ENetSessionFailure failure, const std::string& reason)>Fired once on a client whose session ended for good: the host left (HostEndedSession), the host was lost after the automatic rejoin attempts (HostLost), the player was kicked or banned, or the build differs. The runtime wires it to a travel to the project's start scene; like the travel delegate it is host wiring and survives ClearGameCallbacks.

Constructors

SignatureNameDescription
FNetSession(const FNetSession&) = deleteFNetSession

Public functions

ReturnsNameDescription
FNetSession&Get
voidSetPawnHostFactory
voidSetContentIdentityProvider
voidSetWorldAdapter
boolHostSessionListen server.
boolHostSession
boolJoinSession
boolJoinSession
boolJoinSteamHostSteam lobby / invite handoff — the SteamID64 form makes the composite transport pick the Steam P2P backend.
boolJoinSteamHost
voidEnableInviteHandlingClaim the platform's invite / "Join Game" delegate so accepting one joins THIS session layer instead of opening a bare transport connection.
voidEnableInviteHandling
voidDisableInviteHandling
boolIsInviteHandlingEnabled
voidRebindInviteWorldPoint invite joins at the world that is live now.
voidRebindInviteWorld
uint64_tGetPendingInviteHostHost id of an invite that arrived with no world to join into.
uint64_tConsumePendingInviteHost
uint32_tGetInviteCountInvites accepted since the delegate was claimed, for tests and UI.
voidLeaveSession
boolIsRejoinPendingReconnect / rejoin A client whose link failed while the host still holds its slot keeps enough to come back as the SAME player: the id the host issued, the address it was talking to, and the token that proves the claim.
uint64_tGetRejoinToken
boolRejoinSession
boolRejoinSession
floatGetRejoinGraceSecondsSeconds the HOST holds a dropped player's slot.
voidSetRejoinGraceSeconds
uint32_tGetPendingRejoinCountPlayers whose link is down but whose slot is still held.
uint32_tServerBeginTravel
voidPrepareForWorldSwap
boolCompleteWorldSwap
boolCompleteWorldSwap
voidServerCompleteTravel
boolClientSendTravelAck
voidSetOnTravelRequested
boolIsTravelInProgress
uint32_tGetTravelId
uint32_tGetClientPendingTravelId
const std::string&GetClientPendingTravelScene
boolIsSafeTravelScenePathThe scene a host names for travel is peer data, and the client loads it.
voidTick
ENetSessionStateGetState
ENetSessionFailureGetFailure
boolIsHost
boolIsClient
boolIsInSession
const FNetSessionSettings&GetSettings
std::stringGetJoinKeyWhat a player on another machine needs to join this hosted session directly: "<address>:<port>#<key>".
ENetSessionRouteGetRoute
const std::vector<FNetPlayer>&GetPlayers
uint32_tGetPlayerCount
const FNetPlayer*FindPlayerById
const FNetPlayer*FindPlayerByPeer
const FNetPlayer*GetLocalPlayer
uint32_tGetLocalPlayerId
boolIsSessionFull
voidSetPlayerPawnClassPawn class spawned per connected player.
MClass*GetPlayerPawnClass
voidSetOnPlayerJoined
voidSetOnPlayerLeft
voidSetOnStateChanged
voidSetOnLidarShot
voidSetOnPlayerIntegrityFires on the host when a joining or rejoining client reported a non-zero engine integrity status (a modified build).
voidClearGameCallbacksDrops every game-installed per-session slot: event handlers, client event policies, the player/state/lidar delegates, the RPC fallback and the pawn class.
voidRegisterEventHandlerGameplay events.
voidUnregisterEventHandler
boolHasEventHandler
voidAllowClientEventClient->server events are refused unless allow-listed.
voidDenyClientEvent
boolSendEventToServer
boolSendEventToAllClients
boolSendEventToPlayer
boolBroadcastEventRole-agnostic: on the host runs the handler locally and fans out to every client; on a client asks the server to do that.
boolReportLidarShotThe driving co-op case.
const FLidarShotAuthority&GetLidarShotAuthority
voidFlushPendingShotsShip whatever is queued right now instead of waiting out the coalescing window — for a driver with no clock, and for the last shot before a deliberate leave.
uint32_tGetPendingShotCount
boolWasShotLocallyEchoedTrue when this machine already applied that shot locally, so the server's relay of it must be skipped.
voidSetLocalPlayerStatePacked animation / gameplay word for the local pawn, replicated on the reliable discrete-state stream.
boolGetPlayerState
voidSetRpcFallbackComponent RPCs (a networkId that is not the session sentinel) land here after the default reflection dispatch has run.
voidSetActorRpcInvoker
ENetActorRpcRouteRouteActorRpcShip one named actor RPC toward where its flags say it runs.
voidSetScriptActorRpcInvokerThe same shape for script-defined actors: the blob is the script layer's envelope and the installed invoker is the only reader of it.
ENetActorRpcRouteRouteScriptActorRpc
ReplicationManager*GetReplication
World*GetECSWorld
MWorld*GetGameWorld
uint64_tGetBytesSentToPlayer
uint32_tResolvePeerByteBudgetThe per-client outgoing budget the session actually applies: the settings' per-peer figure, lowered so maxPlayers - 1 clients together fit hostUplinkBytesPerSecond.
boolCheckContentCompatibility
ENetSessionFailureClassifyClientFailureWhat a connecting client's drop or timeout really was: ProtocolMismatch when the replication layer refused the host's packets at the header (version or schema), else fallback.
const std::string&GetLastJoinRefusalReasonAlso the reason a kick or ban carried, on the ejected client.
ENetSessionPhaseGetPhaseHost only.
boolServerStartRun
boolServerReturnToLobby
boolSetLocalReady
boolIsPlayerReady
boolAreAllPlayersReady
voidSetOnPhaseChanged
voidSetOnReturnToMenu
const std::string&GetLastExitReason
uint32_tGetReturnToMenuCount
uint32_tGetAutoRejoinAttemptsLeft
boolKickPlayer
boolBanPlayer
voidBanPlatformId
boolUnbanPlatformId
boolIsPlatformIdBanned
const std::vector<uint64_t>&GetBannedPlatformIds
FNetSession&operator=

Function details

FNetSession

C++
FNetSession(const FNetSession&) = delete

Get

C++
static FNetSession& Get()

SetPawnHostFactory

C++
static void SetPawnHostFactory(FPawnHostFactoryFn factory, FPawnHostReleaseFn release)

SetContentIdentityProvider

C++
static void SetContentIdentityProvider(FContentIdentityFn fn)

SetWorldAdapter

C++
static void SetWorldAdapter(FWorldAdapterFn fn)

HostSession

C++
bool HostSession(MWorld* world, const FNetSessionSettings& settings)

Listen server. The hosting player gets playerId 1 / peerId 0 and a pawn of its own, so host and clients run the same code path.

HostSession

C++
bool HostSession(World* ecsWorld, const FNetSessionSettings& settings)

JoinSession

C++
bool JoinSession(MWorld* world, const std::string& address, uint16_t port, const FNetSessionSettings& settings)

JoinSession

C++
bool JoinSession(World* ecsWorld, const std::string& address, uint16_t port, const FNetSessionSettings& settings)

JoinSteamHost

C++
bool JoinSteamHost(MWorld* world, uint64_t hostSteamId, const FNetSessionSettings& settings)

Steam lobby / invite handoff — the SteamID64 form makes the composite transport pick the Steam P2P backend.

JoinSteamHost

C++
bool JoinSteamHost(World* ecsWorld, uint64_t hostSteamId, const FNetSessionSettings& settings)

EnableInviteHandling

C++
void EnableInviteHandling(MWorld* world, const FNetSessionSettings& settings)

Claim the platform's invite / "Join Game" delegate so accepting one joins THIS session layer instead of opening a bare transport connection. The world and settings are the ones the join will use; a null world parks the invite (GetPendingInviteHost) for a menu that has not built its world yet.

EnableInviteHandling

C++
void EnableInviteHandling(World* ecsWorld, const FNetSessionSettings& settings)

DisableInviteHandling

C++
void DisableInviteHandling()

IsInviteHandlingEnabled

C++
bool IsInviteHandlingEnabled() const

RebindInviteWorld

C++
void RebindInviteWorld(MWorld* world)

Point invite joins at the world that is live now. The stored world is raw, so map travel — which destroys the world invite handling was claimed with — has to hand over the replacement or a later invite joins into freed memory. No-op while invite handling is not claimed.

RebindInviteWorld

C++
void RebindInviteWorld(World* ecsWorld)

GetPendingInviteHost

C++
uint64_t GetPendingInviteHost() const

Host id of an invite that arrived with no world to join into. Consuming it clears the slot, so a menu can drive the join on its own terms.

ConsumePendingInviteHost

C++
uint64_t ConsumePendingInviteHost()

GetInviteCount

C++
uint32_t GetInviteCount() const

Invites accepted since the delegate was claimed, for tests and UI.

LeaveSession

C++
void LeaveSession()

IsRejoinPending

C++
bool IsRejoinPending() const

Reconnect / rejoin A client whose link failed while the host still holds its slot keeps enough to come back as the SAME player: the id the host issued, the address it was talking to, and the token that proves the claim. RejoinSession reconnects to that address and presents the token; the host re-binds the held pawn, its NetworkIds and its ownership, then resyncs the whole world state to it.

GetRejoinToken

C++
uint64_t GetRejoinToken() const

RejoinSession

C++
bool RejoinSession(MWorld* world)

RejoinSession

C++
bool RejoinSession(World* ecsWorld)

GetRejoinGraceSeconds

C++
float GetRejoinGraceSeconds() const

Seconds the HOST holds a dropped player's slot. Negative in the settings means "follow net.rejoin_grace_seconds"; the resolved value is here.

SetRejoinGraceSeconds

C++
void SetRejoinGraceSeconds(float seconds)

GetPendingRejoinCount

C++
uint32_t GetPendingRejoinCount() const

Players whose link is down but whose slot is still held.

ServerBeginTravel

C++
uint32_t ServerBeginTravel(const std::string& scenePath)

PrepareForWorldSwap

C++
void PrepareForWorldSwap()

CompleteWorldSwap

C++
bool CompleteWorldSwap(MWorld* world)

CompleteWorldSwap

C++
bool CompleteWorldSwap(World* ecsWorld)

ServerCompleteTravel

C++
void ServerCompleteTravel()

ClientSendTravelAck

C++
bool ClientSendTravelAck(uint32_t travelId)

SetOnTravelRequested

C++
void SetOnTravelRequested(TravelDelegate d)

IsTravelInProgress

C++
bool IsTravelInProgress() const

GetTravelId

C++
uint32_t GetTravelId() const

GetClientPendingTravelId

C++
uint32_t GetClientPendingTravelId() const

GetClientPendingTravelScene

C++
const std::string& GetClientPendingTravelScene() const

IsSafeTravelScenePath

C++
static bool IsSafeTravelScenePath(const std::string& scenePath)

The scene a host names for travel is peer data, and the client loads it. Only a relative content path passes: an absolute or drive-qualified path skips the VFS mounts, a UNC path makes the client authenticate to that share, and a ".." segment climbs out of the content tree.

Tick

C++
void Tick(float deltaSeconds)

GetState

C++
ENetSessionState GetState() const

GetFailure

C++
ENetSessionFailure GetFailure() const

IsHost

C++
bool IsHost() const

IsClient

C++
bool IsClient() const

IsInSession

C++
bool IsInSession() const

GetSettings

C++
const FNetSessionSettings& GetSettings() const

GetJoinKey

C++
std::string GetJoinKey() const

What a player on another machine needs to join this hosted session directly: "<address>:<port>#<key>". Empty when not hosting, or when the link authenticates otherwise (a configured net.psk, Steam).

GetRoute

C++
ENetSessionRoute GetRoute() const

GetPlayers

C++
const std::vector<FNetPlayer>& GetPlayers() const

GetPlayerCount

C++
uint32_t GetPlayerCount() const

FindPlayerById

C++
const FNetPlayer* FindPlayerById(uint32_t playerId) const

FindPlayerByPeer

C++
const FNetPlayer* FindPlayerByPeer(uint32_t peerId) const

GetLocalPlayer

C++
const FNetPlayer* GetLocalPlayer() const

GetLocalPlayerId

C++
uint32_t GetLocalPlayerId() const

IsSessionFull

C++
bool IsSessionFull() const

SetPlayerPawnClass

C++
void SetPlayerPawnClass(MClass* pawnClass)

Pawn class spawned per connected player. Null falls back to a bare Transform + NetworkObject entity, which is what a headless driver and the self-test use.

GetPlayerPawnClass

C++
MClass* GetPlayerPawnClass() const

SetOnPlayerJoined

C++
void SetOnPlayerJoined(PlayerDelegate d)

SetOnPlayerLeft

C++
void SetOnPlayerLeft(PlayerDelegate d)

SetOnStateChanged

C++
void SetOnStateChanged(StateDelegate d)

SetOnLidarShot

C++
void SetOnLidarShot(LidarShotDelegate d)

SetOnPlayerIntegrity

C++
void SetOnPlayerIntegrity(PlayerDelegate d)

Fires on the host when a joining or rejoining client reported a non-zero engine integrity status (a modified build). The server's own code decides what to do — kick, flag for review, tell a match service. The default without a handler is log-only; it never changes gameplay. The FNetPlayer carries the bits in integrityBits, and is also delivered to OnPlayerJoined with them set, so an existing join handler can read them.

ClearGameCallbacks

C++
void ClearGameCallbacks()

Drops every game-installed per-session slot: event handlers, client event policies, the player/state/lidar delegates, the RPC fallback and the pawn class. LeaveSession calls it — the installers live in game code (often the hot-reloadable game module), and a std::function carries no address the session could attribute to an image, so the slots cannot be allowed to outlive the session they were set up for. Install your handlers when starting a session, not once per process. The travel delegate stays: it is engine-host wiring with its own lifetime (the runtime clears it in StopGame).

RegisterEventHandler

C++
void RegisterEventHandler(uint16_t eventId, EventHandler handler)

Gameplay events. Ids must sit at or above kGameEventFirst; the reserved block above kReservedFirst belongs to the join protocol.

UnregisterEventHandler

C++
void UnregisterEventHandler(uint16_t eventId)

HasEventHandler

C++
bool HasEventHandler(uint16_t eventId) const

AllowClientEvent

C++
void AllowClientEvent(uint16_t eventId, bool ownerOnly = true, ENetEventRate rate = ENetEventRate::Default)

Client->server events are refused unless allow-listed. OwnerOnly (the default) additionally requires the sender to own the pawn the event is stamped with — the correct setting for anything a pawn does.

DenyClientEvent

C++
void DenyClientEvent(uint16_t eventId)

SendEventToServer

C++
bool SendEventToServer(uint16_t eventId, const FNetEventWriter& payload)

SendEventToAllClients

C++
bool SendEventToAllClients(uint16_t eventId, const FNetEventWriter& payload)

SendEventToPlayer

C++
bool SendEventToPlayer(uint32_t playerId, uint16_t eventId, const FNetEventWriter& payload)

BroadcastEvent

C++
bool BroadcastEvent(uint16_t eventId, const FNetEventWriter& payload)

Role-agnostic: on the host runs the handler locally and fans out to every client; on a client asks the server to do that. The call site a game writes for "this happened".

ReportLidarShot

C++
bool ReportLidarShot(const FNetLidarShot& shot)

The driving co-op case. Scans replicate as one shot record, never as point clouds — the receiving side regenerates the points. The shooter's own scan is applied LOCALLY the instant this is called, so the beam is not one round trip late on the machine that fired it, and the server's relay of that same scan is recognised by its shot id and skipped rather than painted twice. Shots are coalesced for settings.shotCoalesceSeconds and shipped as one batch on the high-rate channel; Tick does the flush, so a session that stops ticking does not strand them.

GetLidarShotAuthority

C++
const FLidarShotAuthority& GetLidarShotAuthority() const

FlushPendingShots

C++
void FlushPendingShots()

Ship whatever is queued right now instead of waiting out the coalescing window — for a driver with no clock, and for the last shot before a deliberate leave.

GetPendingShotCount

C++
uint32_t GetPendingShotCount() const

WasShotLocallyEchoed

C++
bool WasShotLocallyEchoed(uint32_t shotId, uint32_t shooterPlayerId) const

True when this machine already applied that shot locally, so the server's relay of it must be skipped. Keyed on the shooter as well as the id: two players' shot counters run independently and would collide.

SetLocalPlayerState

C++
void SetLocalPlayerState(const FNetPlayerState& state)

Packed animation / gameplay word for the local pawn, replicated on the reliable discrete-state stream.

GetPlayerState

C++
bool GetPlayerState(uint32_t playerId, FNetPlayerState& outState) const

SetRpcFallback

C++
void SetRpcFallback(RpcFallback fallback)

Component RPCs (a networkId that is not the session sentinel) land here after the default reflection dispatch has run.

SetActorRpcInvoker

C++
static void SetActorRpcInvoker(FActorRpcInvokeFn fn)

RouteActorRpc

C++
ENetActorRpcRoute RouteActorRpc(NetworkId nid, uint16_t rpcFlags, const uint8_t* data, size_t len)

Ship one named actor RPC toward where its flags say it runs. nid is the target actor's replication id, rpcFlags the function's reflected flags (Server/Client/Multicast decide the direction). Returns RunLocal when the destination resolves to this machine (Client RPC on a host-owned actor) — the caller invokes locally then.

SetScriptActorRpcInvoker

C++
static void SetScriptActorRpcInvoker(FActorRpcInvokeFn fn)

The same shape for script-defined actors: the blob is the script layer's envelope and the installed invoker is the only reader of it. unreliable picks the high-rate class and the unreliable channel. Direction comes from the flags exactly as RouteActorRpc reads them.

RouteScriptActorRpc

C++
ENetActorRpcRoute RouteScriptActorRpc(NetworkId nid, uint16_t rpcFlags, bool unreliable, const uint8_t* data, size_t len)

GetReplication

C++
ReplicationManager* GetReplication() const

GetECSWorld

C++
World* GetECSWorld() const

GetGameWorld

C++
MWorld* GetGameWorld() const

GetBytesSentToPlayer

C++
uint64_t GetBytesSentToPlayer(uint32_t playerId) const

ResolvePeerByteBudget

C++
static uint32_t ResolvePeerByteBudget(const FNetSessionSettings& settings)

The per-client outgoing budget the session actually applies: the settings' per-peer figure, lowered so maxPlayers - 1 clients together fit hostUplinkBytesPerSecond.

CheckContentCompatibility

C++
static bool CheckContentCompatibility(const std::string& localBuildId, uint64_t localDlcHash, const std::string& remoteBuildId, uint64_t remoteDlcHash, std::string& outReason)

ClassifyClientFailure

C++
static ENetSessionFailure ClassifyClientFailure(uint32_t versionMismatches, uint32_t schemaMismatches, ENetSessionFailure fallback, std::string& outReason)

What a connecting client's drop or timeout really was: ProtocolMismatch when the replication layer refused the host's packets at the header (version or schema), else fallback. Fills the reason for the UI.

GetLastJoinRefusalReason

C++
const std::string& GetLastJoinRefusalReason() const

Also the reason a kick or ban carried, on the ejected client.

GetPhase

C++
ENetSessionPhase GetPhase() const

Host only. A kicked player is told why (kKicked), released at once — never held for rejoin, the hold is for a link that dropped, not one the host cut — and disconnected; the other clients get the usual kPlayerLeft. A ban is a kick whose platform id is refused at the next join request for the life of this hosted session (LeaveSession clears the list; persisting bans across sessions is the game's job). A player with no platform id (LAN, no online service) can only be kicked. The host and the local player refuse both. The phase is the host's; clients follow kSessionPhase. ServerStartRun refuses while anyone connected is not ready unless forced, and ServerReturnToLobby clears every ready flag for the next run. With lateJoinPolicy = LobbyOnly a new player is refused InRun (RunInProgress) while a held slot can still be rejoined.

ServerStartRun

C++
bool ServerStartRun(bool force = false)

ServerReturnToLobby

C++
bool ServerReturnToLobby()

SetLocalReady

C++
bool SetLocalReady(bool ready)

IsPlayerReady

C++
bool IsPlayerReady(uint32_t playerId) const

AreAllPlayersReady

C++
bool AreAllPlayersReady() const

SetOnPhaseChanged

C++
void SetOnPhaseChanged(PhaseDelegate d)

SetOnReturnToMenu

C++
void SetOnReturnToMenu(ReturnToMenuDelegate d)

GetLastExitReason

C++
const std::string& GetLastExitReason() const

GetReturnToMenuCount

C++
uint32_t GetReturnToMenuCount() const

GetAutoRejoinAttemptsLeft

C++
uint32_t GetAutoRejoinAttemptsLeft() const

KickPlayer

C++
bool KickPlayer(uint32_t playerId, const std::string& reason)

BanPlayer

C++
bool BanPlayer(uint32_t playerId, const std::string& reason)

BanPlatformId

C++
void BanPlatformId(uint64_t platformId)

UnbanPlatformId

C++
bool UnbanPlatformId(uint64_t platformId)

IsPlatformIdBanned

C++
bool IsPlatformIdBanned(uint64_t platformId) const

GetBannedPlatformIds

C++
const std::vector<uint64_t>& GetBannedPlatformIds() const

operator=

C++
FNetSession& operator=(const FNetSession&) = delete
Generated from Networking/Session/FNetSession.h via networking.json · Nov 4, 2026Version 1.0.0