ReplicationManager
Drives the server/client side of state replication for every entity carrying a NetworkObjectComponent. Owned by the World; registered in runtime + simulation system sets.
- Module
- Networking
- Header
#include "Networking/Replication/ReplicationManager.h"- Namespace
Mowo
Lifecycle: - Host (server): every tick scans NetworkObjectComponents, allocates a NetworkId to any newly-added one + broadcasts a Spawn packet, and at the configured snapshot rate (~20 Hz) bundles every owned transform into a Snapshot broadcast. Destroyed entities → Destroy packet. - Client: registers a NetworkManager filter to intercept replication packets. On Spawn, instantiates the prefab and tags the entity with the server-assigned NetworkId. On Snapshot, applies the transform to the matching ghost. On Destroy, removes the ghost.
Replication is reflection-driven: PropertyReplicator diffs the MREPLICATED fields of a component's TypeDescriptor and ships only what changed. The replicating component set comes from FReplicatedComponentRegistry — every reflected component with MREPLICATED fields is in it, and per object the set is whatever that entity actually carries. Continuous fields ride the unreliable Snapshot, discrete ones the reliable StateSnapshot; a component with both appears on both streams.
Type aliases
| Alias | Description |
|---|---|
using FSlotReleaseFn = void (*)(void* context) | Frees the context handed to one of the slot installers below. Supplied by the installer so the free runs in the installer's image; null when the context is not owned (a this pointer, a stack frame). |
using FGhostSpawnFn = uint64_t (*)(World& world, const FGhostSpawnDesc& desc) | |
using FGhostDestroyFn = void (*)(World& world, uint64_t entity) | |
using FGhostReleaseFn = void (*)(World& world) | Release hook: the session is over, so anything this manager wrote onto entities the GAME owns has to be handed back. A scene-placed object that a Spawn adopted carries this session's NetworkId in a component the scene owns, and nothing else clears it — the next join would then skip the twin it already adopted and materialize a second copy of it. This module cannot reach a Scene (it sits below Game), so the reaction is installed from up there alongside spawn/destroy and called with the world it belongs to. |
using FSessionPumpFn = void (*)(float deltaTime) | Session pump: the session state machine ticks ahead of the replication tick (a pawn spawned for a joining player must carry its NetworkId before this tick builds spawns/snapshots). FNetSession still lives above this module until N4; whoever owns it installs the pump. |
using FNetRefResolvedFn = std::function<void(uint64_t entity)> | Replicated object references (UE's NetGUID, minus the guesswork): a component field that "points at" another networked object holds its NetworkId (MREPLICATED uint32_t). The id can arrive before the object it names — a reliable state delta overtaking an unreliable spawn's relevancy, or a reference to something not yet relevant. This calls fn with the entity at once when the id is known, else when the Spawn that maps it lands; ending the session drops every wait. Returns false when the call was deferred. |
using FPacketSinkFn = void (*)(void* context, uint32_t peerId, const uint8_t* data, size_t len, NetworkChannel channel) | Outgoing packet sink. Defaults to the live transport; a headless driver (tests, bots, a record/replay harness) can capture instead. |
using FRpcReceiverFn = void (*)(void* context, NetworkId nid, uint16_t methodId, uint16_t methodIndex, const uint8_t* args, size_t argLen, uint32_t senderPeerId) | Incoming RPC handler. Called on the game thread right after the packet is decoded. The byte* lifetime is the call only — the handler must copy if it needs the buffer afterward. The slot has ONE owner. Installing over an occupied slot is refused with an error naming the owner instead of silently displacing it — last-writer-wins here meant that whichever of FNetSession and a game's own actor ran second decided whether RPCs worked at all. A second subscriber uses AddRpcObserver, which runs after the owner. |
using FPeerAuthFn = bool (*)(void* context, uint32_t peerId) | Authentication gate. When set (the dedicated server installs it once ticket auth is on), an unauthenticated peer's Input/RPC is dropped before it can touch the authoritative sim — auth runs ahead of replication, not behind it. Unset (the shipped default) means every registered peer is allowed, matching the no-auth listen-server case. |
using PendingInput = FPendingInput | Snapshot of pending input buffer — user code walks it during reconciliation to replay each pending tick's input. |
using FReconcileFn = void (*)(void* context, uint32_t newAckTick) | |
using FInputReceiverFn = void (*)(void* context, uint32_t senderPeerId, const ReplicationInputBody& body) | Server-side: invoked when an Input packet arrives. Receiver gets (senderPeerId, body) — gameplay code knows which NetworkObject the peer owns (it set ownerPeerId at spawn) and applies the input to the entity's simulation. The framework can't do this generically because "what does this input mean" depends on the game (walking vs flying vs vehicle steering). |
Properties
| Type | Name | Description |
|---|---|---|
static constexpr float | kDefaultServerTickHz | Default 30.0f. |
static constexpr float | kDefaultSnapshotHz | Default 20.0f. |
static constexpr uint16_t | kActorNamedRpcMethodId | RPC dispatch Reserved methodId for actor-level NAMED RPCs (Visual Scripting / MFUNCTION routing): the arg blob carries the function name + marshalled args, and the receiving side resolves the function on the target actor's MClass chain. Sits at the top of the sub-0x8000 space so it can never collide with a real componentId (those are allocated sequentially from registration and number in the hundreds). methodIndex is always 0 on this id. Default 0x7FFF. |
static constexpr uint16_t | kScriptActorRpcMethodId | Reserved methodId for the script actor lane (Wolang): the blob is the script layer's own envelope (replicated field batches and RPC calls) and its dispatcher is the only judge of what it names. methodIndex picks the rate class and channel, never a method: 0 is reliable on the default bucket, 1 is unreliable on the high-rate bucket (a replicated field or RPC declared (unreliable)). Both indices are client-callable OwnerOnly, the same grant the named actor lane has. Default 0x7FFE. |
static constexpr uint16_t | kScriptActorRpcReliable | Default 0. |
static constexpr uint16_t | kScriptActorRpcUnreliable | Default 1. |
Constructors
| Signature | Name | Description |
|---|---|---|
ReplicationManager() | ReplicationManager | |
~ReplicationManager() override | ~ReplicationManager | |
ReplicationManager(const ReplicationManager&) = delete | ReplicationManager |
Public functions
| Returns | Name | Description |
|---|---|---|
ReplicationManager& | operator= | |
void | Initialize | |
void | Shutdown | |
void | Update | |
void* | MakeSlotContext | Wrap a capturing callable so the manager stores nothing but pointers. |
void | InvokeRpcHolder | Thunk for the RPC receiver shape, shared by the three installers that take one. |
void | ClearGameCallbacks | Drops every game-installed callback slot on this manager: the RPC receiver and its observers, the input receiver, the peer-auth predicate, the reconcile callback and the packet sink. |
void | SetGhostProvider | |
void | EndSession | The session ended on THIS manager — a leave, a dropped host, or a world swap. |
void | SetSessionPump | |
void | SetSnapshotRateHz | Tune the tick rates at runtime — useful for tests and for games that ship faster snapshots on LAN-only modes. |
void | SetServerTickRateHz | The fixed server tick the lag-compensation history is indexed by. |
float | GetServerTickRateHz | |
void | SetInterpolationDelay | Client-side render delay (seconds). |
float | GetInterpolationDelay | |
uint32_t | GetServerTick | Tick counter the server advances at the fixed server tick rate (not the snapshot rate). |
uint32_t | GetClientViewServerTick | Client-side: the server tick of the snapshot the interpolated ghosts are drawn FROM this frame — what the player aimed at. |
uint64_t | FindEntityByNetworkId | NetworkId → entity lookup for RPC receivers: wire together with FRpcDispatcher::DispatchComponentRpc in SetRpcReceiver. |
bool | WhenNetworkIdResolves | |
size_t | GetPendingNetRefCount | |
void | RegisterReplicatedActor | Actor-level replication attach point. |
void | UnregisterReplicatedActor | |
uint64_t | FindEntityByActor | Backing entity of a registered actor, or INVALID_ENTITY when the actor was never registered (or carries no backing entity). |
AActor* | FindActorByEntity | Actor registered for a backing entity, or nullptr. |
AActor* | FindActorByNetworkId | Actor behind a live NetworkId — net → entity → actor. |
uint16_t | BuildSnapshotInto | Build the current Snapshot packet into out and return the entry count. |
void | ScheduleNetUpdates | UE's NetUpdateFrequency and dormancy, decided once per snapshot tick before any peer's snapshot is built (ServerTick calls it; a headless driver calls it itself). |
void | FlushNetDormancy | One update for a dormant object at the next scheduled tick, without waking it (UE's FlushNetDormancy). |
uint64_t | GetNetUpdateSkips | |
void | MarkNetDirty | Push model (NetworkObjectComponent::netPushModel): record that the object's replicated state changed. |
void | MarkNetDirty | |
uint64_t | GetNetPushSkips | Objects a path skipped without diffing because they were clean. |
uint64_t | GetContinuousDiffCount | Component diffs performed by the continuous paths (measurement and the push-model row: a clean object must not add to it). |
uint32_t | GetLastRelevancyCandidateVisits | Candidates the relevancy sweep tested against a peer's viewer in the last step, summed over peers; with the spatial grid only the viewer's cell and the always-tested list are visited. |
uint16_t | BuildStateSnapshotInto | Build the RELIABLE StateSnapshot packet into out and return the entry count. |
uint8_t | GetProtocolVersion | Wire identity this build speaks. |
uint16_t | GetSchemaId | |
bool | HandleIncomingPacket | Decode one incoming replication packet. |
bool | OnIncomingPacket | The NetworkManager filter itself. |
const FProtocolStats& | GetProtocolStats | |
void | ResetProtocolStats | |
void | SetPeerByteBudgetPerSecond | Relevancy / interest management (UE NetCullDistance + NetPriority). |
uint32_t | GetPeerByteBudgetPerSecond | |
uint64_t | GetPeerBytesSent | |
uint32_t | GetPeerByteTokens | |
uint64_t | GetPeerVoiceBytesCharged | |
uint32_t | GetPeerBudgetDeferrals | |
uint64_t | GetTotalBytesSent | |
void | SetPeerInboundByteBudgetPerSecond | The same bucket in the other direction, and the one that was missing entirely. |
uint32_t | GetPeerInboundByteBudgetPerSecond | |
uint64_t | GetPeerBytesReceived | |
uint32_t | GetPeerInboundByteTokens | |
uint32_t | GetPeerInboundDrops | |
void | ServerAssignNetworkIds | Assign a NetworkId to every NetworkObjectComponent that lacks one and (relevancy off) broadcast its Spawn. |
std::vector<uint32_t> | GetPeerIds | Registered peer ids, in unspecified order. |
NetworkId | FindNetworkIdByEntity | Session-local id of a replicated entity, or INVALID_NETWORK_ID. |
void | SetRelevancyEnabled | |
bool | IsRelevancyEnabled | |
void | SetMaxUpdatesPerTick | |
void | SetMaxSnapshotBytes | |
void | SetStarvationTicks | |
void | SetDefaultCullDistance | |
float | GetDefaultCullDistance | |
uint32_t | GetMaxUpdatesPerTick | |
uint32_t | GetMaxSnapshotBytes | |
uint32_t | GetReplicatedObjectCount | |
uint32_t | GetPeerCount | |
float | GetSnapshotRateHz | |
void | RegisterPeer | The server tracks one relevancy state per connected client. |
void | UnregisterPeer | |
bool | HasPeer | |
void | ServerResyncPeer | |
void | ServerDetectOwnerChanges | |
uint32_t | GetOwnerChangeResyncCount | |
FNetBlobChannel& | GetBlobChannel | |
const FNetBlobChannel& | GetBlobChannel | |
uint32_t | GetRpcBlobThreshold | |
FSpatialStreamServer& | GetSpatialServer | The keyed delta stream (chunk edits and the like). |
FSpatialStreamClient& | GetSpatialClient | |
void | ClientSetSpatialInterest | |
void | RegisterFastArray | Fast arrays (UE's FFastArraySerializer). |
void | UnregisterFastArray | |
uint32_t | GetFastArrayDeltasSent | |
uint32_t | GetFastArrayDeltasApplied | |
void | SetPeerViewer | Where the client "is". |
void | SetPeerRelevancyGroups | Which NetworkObjectComponent::netRelevancyGroups this peer belongs to (all by default). |
uint32_t | GetPeerRelevancyGroups | |
void | SetPeerViewEntity | |
bool | IsRelevantTo | True when nid is currently replicated to peerId (the client owns a ghost for it). |
void | SetPacketSink | |
void | ClearPacketSink | |
void | SetPacketSink | Convenience for a capturing callable. |
void | ServerRelevancyStep | One relevancy pass: reap destroyed objects, then per client emit Spawn (entered) / Destroy (left) / Snapshot (budgeted). |
void | ServerBroadcastSnapshot | One non-relevancy snapshot pass: builds this tick's continuous (unreliable) + discrete (reliable) deltas and ships them to every registered peer, each stamped with that peer's ack. |
const FRelevancyStats& | GetRelevancyStats | |
bool | SendRpcToAllClients | Manual routing: the caller picks the direction. |
bool | SendRpcToClient | |
bool | SendRpcToServer | |
bool | SetRpcReceiver | |
void | ClearRpcReceiver | |
bool | HasRpcReceiver | |
const char* | GetRpcReceiverOwner | |
bool | SetRpcReceiver | |
void | TakeRpcReceiver | Engine-level claim: takes the slot even when something else holds it, logging the displacement. |
void | TakeRpcReceiver | |
uint32_t | AddRpcObserver | |
uint32_t | AddRpcObserver | |
void | RemoveRpcObserver | |
void | ClearRpcObservers | |
bool | HasRpcObserver | True while the observer behind handle is still installed. |
void | SetPeerAuthPredicate | |
void | ClearPeerAuthPredicate | |
void | SetPeerAuthPredicate | |
void | SetRpcChannelClass | |
ENetRpcChannelClass | GetRpcChannelClass | |
void | ClearRpcChannelClasses | |
NetworkChannel | DefaultChannelForRpcClass | The channel a method of this class rides unless the caller names one. |
void | AllowClientRpc | |
void | DenyClientRpc | |
void | AllowClientRpcHighRate | Allow-list and rate-class in one call — the shape a high-rate verb wants, so the two halves cannot drift apart at the call site. |
void | AllowClientRpcComponent | Component-wide grant — the pre-v3 blast radius, kept as an explicit convenience for a component whose every method shares one policy. |
void | DenyClientRpcComponent | |
void | ClearClientRpcPolicy | |
ENetRpcAuthority | GetClientRpcAuthority | |
void | InstallAnnotatedRpcPolicies | Walk every reflected component's MFUNCTION table and install the policy its RPC-direction annotations imply: a Server method becomes AllowClientRpc(component, index, OwnerOnly); Client / Multicast methods stay client-denied (they are server→client only). |
void | SetRpcRateLimit | Per-peer token buckets over the two client→server paths a peer can flood (ENet is created with both bandwidth limits at zero, so nothing below us throttles). |
void | SetInputRateLimit | |
void | SetHighRateRpcLimit | The HighRate bucket, charged only by methods registered SetRpcChannelClass(..., HighRate). |
uint32_t | GetHighRateRpcLimit | |
void | ServerRefillRateLimits | Refill every peer's buckets. |
const FRpcSecurityStats& | GetRpcSecurityStats | |
void | ResetRpcSecurityStats | |
bool | ServerHandleClientRpc | Server-side entry point for an incoming client→server RPC, policy included. |
void | ServerApplyAck | Ack-driven delta baselines A peer's per-object baseline advances only when the packet carrying the new state is acknowledged. |
uint32_t | GetPeerLastAckedPacketId | |
void | SetMaxUnackedSends | Bounding the resend Re-sending an unacked delta every tick is what repairs a dropped snapshot, and it is also unbounded: a peer that stops acking costs one entry per object per tick for as long as it stays connected. |
void | SetAckProbeInterval | |
bool | IsPeerAckStalled | |
uint32_t | GetPeerUnackedSends | |
void | ClientSendAck | Client-side: send an Ack for the highest snapshot packetId seen. |
void | RecordClientInput | Client-side prediction The framework only provides bookkeeping — actual prediction logic is gameplay-specific and lives in user code (a script reads GetUnacknowledgedInputs, replays them against the entity's owned state, etc.). |
void | RecordPredictedInput | Record a locally-predicted input into the pending ring WITHOUT shipping it (no transport / role gate). |
void | ClientApplyServerAck | Client-side: a server→client packet carried a fresh per-peer last-processed-input tick. |
void | ServerRecordProcessedInput | Server-side: remember the highest input tick processed for peerId. |
uint32_t | GetPeerLastProcessedInput | |
bool | TryGetAuthoritativeTransform | Latest AUTHORITATIVE ghost pose the client has decoded for nid (the raw snapshot state, before interpolation). |
bool | TryGetReplicatedNetState | Latest decoded DISCRETE replicated state (netState) for a ghost — the value the reliable StateSnapshot stream converged to. |
const void* | TryGetReplicatedComponent | Latest decoded bytes of any OTHER replicated component on a ghost, and the reflected field read off them. |
bool | TryGetReplicatedField | |
uint32_t | GetLastAcknowledgedClientTick | |
uint32_t | GetClientTick | |
const std::vector<PendingInput>& | GetPendingInputs | |
void | SetReconcileCallback | |
void | ClearReconcileCallback | |
void | SetReconcileCallback | |
void | SetInputReceiver | |
void | ClearInputReceiver | |
void | SetInputReceiver | |
void | SetInputAckDeferred | True for a receiver that only queues a move and simulates it later: the manager then leaves the ack to it (ServerRecordProcessedInput once the move has run), so the tick a client reconciles against names a state the server actually computed. |
bool | RewindTo | Lag compensation Server-side authoritative history. |
void | RestorePresent | |
void | SetLagCompHistoryTicks |
Function details
ReplicationManager
ReplicationManager()~ReplicationManager
~ReplicationManager() overrideReplicationManager
ReplicationManager(const ReplicationManager&) = deleteoperator=
ReplicationManager& operator=(const ReplicationManager&) = deleteInitialize
void Initialize(World* world) overrideShutdown
void Shutdown() overrideUpdate
void Update(float deltaTime) overrideMakeSlotContext
template<typename F> static void* MakeSlotContext(F&& fn, FSlotReleaseFn& outRelease)Wrap a capturing callable so the manager stores nothing but pointers. The holder is new'd and delete'd by this template, which is instantiated in the CALLING translation unit — so allocation, the callable's copy and its destructor all happen in the installer's image. That is the whole point: a std::function member did those in whichever image happened to touch the slot, which is the ABI hazard across a DLL boundary.
InvokeRpcHolder
template<typename Holder> static void InvokeRpcHolder(void* context, NetworkId nid, uint16_t methodId, uint16_t methodIndex, const uint8_t* args, size_t argLen, uint32_t senderPeerId)Thunk for the RPC receiver shape, shared by the three installers that take one. Instantiated in the caller's TU, like the holder it unwraps.
ClearGameCallbacks
void ClearGameCallbacks()Drops every game-installed callback slot on this manager: the RPC receiver and its observers, the input receiver, the peer-auth predicate, the reconcile callback and the packet sink. The targets almost always live OUTSIDE this module — the hot-reloadable game module, or a test's stack frame. The manager itself outlives both (it is a World system, and a session comes and goes underneath it), so a slot left occupied is a call into freed pages the next time a packet arrives. Session teardown comes through here. The module-unload broadcast does NOT: now that a slot carries the addresses it was installed from, it drops only the slots the dying module owns and leaves everyone else's alone. The RPC POLICY is not touched either: it is data, not code, and ClearClientRpcPolicy owns it.
SetGhostProvider
static void SetGhostProvider(FGhostSpawnFn spawn, FGhostDestroyFn destroy, FGhostReleaseFn release)EndSession
void EndSession()The session ended on THIS manager — a leave, a dropped host, or a world swap. The manager is a World system and outlives the session, so its per-session tables and the marks it left on game-owned entities both have to go: a NetworkId reused by the next session would otherwise fail to overwrite its stale entry and drive the previous session's entity.
SetSessionPump
static void SetSessionPump(FSessionPumpFn fn)SetSnapshotRateHz
void SetSnapshotRateHz(float hz)Tune the tick rates at runtime — useful for tests and for games that ship faster snapshots on LAN-only modes.
SetServerTickRateHz
void SetServerTickRateHz(float hz)The fixed server tick the lag-compensation history is indexed by. It runs independently of the snapshot cadence: m_lagCompHistoryTicks ticks of history mean the same 500 ms whether snapshots go out at 20 Hz or a LAN mode ships them at 60. The dedicated server feeds --tickrate here.
GetServerTickRateHz
float GetServerTickRateHz() constSetInterpolationDelay
void SetInterpolationDelay(float seconds)Client-side render delay (seconds). The interpolation system plays back snapshots this much behind the most recent one — at 100ms / 20Hz tick that's ~2 snapshots of buffer, which absorbs jitter and a dropped snapshot or two without the ghost stalling. (It does NOT recover reordered packets: the unreliable channel is sequenced, so the transport drops anything older than the newest already delivered.) Default tracks the Source-style 100ms convention.
GetInterpolationDelay
float GetInterpolationDelay() constGetServerTick
uint32_t GetServerTick() constTick counter the server advances at the fixed server tick rate (not the snapshot rate). Embedded in every outgoing packet so clients can detect out-of-order delivery on the Unreliable channel, and the key the lag-compensation history is rewound by.
GetClientViewServerTick
uint32_t GetClientViewServerTick() constClient-side: the server tick of the snapshot the interpolated ghosts are drawn FROM this frame — what the player aimed at. A hitscan sends it so the server can RewindTo it; the present server tick is an interpolation delay plus half a round trip ahead of what was on screen. 0 before the first snapshot.
FindEntityByNetworkId
uint64_t FindEntityByNetworkId(NetworkId nid) constNetworkId → entity lookup for RPC receivers: wire together with FRpcDispatcher::DispatchComponentRpc in SetRpcReceiver.
WhenNetworkIdResolves
bool WhenNetworkIdResolves(NetworkId nid, FNetRefResolvedFn fn)GetPendingNetRefCount
size_t GetPendingNetRefCount() constRegisterReplicatedActor
void RegisterReplicatedActor(AActor* actor, uint64_t entity)Actor-level replication attach point. Replication addresses ECS entities that carry a NetworkObjectComponent; gameplay owns AActors. Registering an actor records the actor ↔ backing entity mapping so the actor-property replication path can resolve a NetworkId back to the owning gameplay actor, not just its entity. This is the address book that path reads — the actor MREPLICATED field deltas that ride it land in a later phase; the attach surface is here so the wiring has a stable place to hang off. The entity is passed in rather than read off the actor — this class lives below the actor framework and treats AActor* as an opaque key (E3.1 N3); callers hand over actor->GetBackingEntity().
UnregisterReplicatedActor
void UnregisterReplicatedActor(AActor* actor)FindEntityByActor
uint64_t FindEntityByActor(const AActor* actor) constBacking entity of a registered actor, or INVALID_ENTITY when the actor was never registered (or carries no backing entity).
FindActorByEntity
AActor* FindActorByEntity(uint64_t entityId) constActor registered for a backing entity, or nullptr.
FindActorByNetworkId
AActor* FindActorByNetworkId(NetworkId nid) constActor behind a live NetworkId — net → entity → actor. nullptr when the id is unknown or its entity has no registered actor.
BuildSnapshotInto
uint16_t BuildSnapshotInto(std::vector<uint8_t>& out)Build the current Snapshot packet into out and return the entry count. Field-level deltas: each entry is [networkId][uint8 componentSlot] [uint16 deltaLen][PropertyReplicator delta] carrying ONLY the MREPLICATED fields of that component that changed since the per-object baseline (first send force-includes all of them). Idle objects cost zero bandwidth; a moving object costs its changed fields, not the whole transform. Public so it can be driven headlessly without a live socket.
ScheduleNetUpdates
void ScheduleNetUpdates()UE's NetUpdateFrequency and dormancy, decided once per snapshot tick before any peer's snapshot is built (ServerTick calls it; a headless driver calls it itself). An object that is dormant, or not due at its NetworkObjectComponent::netUpdateFrequency, is skipped by every continuous snapshot path this tick — not diffed, not sent — where every object used to be diffed for every peer every tick. Its Spawn still reaches a client it becomes relevant to, and its discrete (reliable) state still ships on change.
FlushNetDormancy
void FlushNetDormancy(uint64_t entityId)One update for a dormant object at the next scheduled tick, without waking it (UE's FlushNetDormancy).
GetNetUpdateSkips
uint64_t GetNetUpdateSkips() constMarkNetDirty
void MarkNetDirty(uint64_t entityId)Push model (NetworkObjectComponent::netPushModel): record that the object's replicated state changed. Every path that would diff the object (per-peer snapshots, the relevancy sweep, the headless fallback and the discrete stream) skips it while its change serial still equals the one at which that path last saw it converge. The static form is for code that already holds the component.
MarkNetDirty
static void MarkNetDirty(NetworkObjectComponent& no)GetNetPushSkips
uint64_t GetNetPushSkips() constObjects a path skipped without diffing because they were clean.
GetContinuousDiffCount
uint64_t GetContinuousDiffCount() constComponent diffs performed by the continuous paths (measurement and the push-model row: a clean object must not add to it).
GetLastRelevancyCandidateVisits
uint32_t GetLastRelevancyCandidateVisits() constCandidates the relevancy sweep tested against a peer's viewer in the last step, summed over peers; with the spatial grid only the viewer's cell and the always-tested list are visited.
BuildStateSnapshotInto
uint16_t BuildStateSnapshotInto(std::vector<uint8_t>& out)Build the RELIABLE StateSnapshot packet into out and return the entry count. Carries only the DISCRETE replicated fields (health, ammo, state enums, NetworkObjectComponent::netState) that changed since the per-object state baseline; these ship on the reliable channel so a dropped packet never strands a client on a stale value. Continuous fields stay in BuildSnapshotInto (unreliable, self-healing). Public so it can be driven headlessly without a socket.
GetProtocolVersion
uint8_t GetProtocolVersion() constWire identity this build speaks. Both ride in every packet header; a peer that disagrees is refused (see HandleIncomingPacket).
GetSchemaId
uint16_t GetSchemaId() constHandleIncomingPacket
bool HandleIncomingPacket(uint32_t senderPeerId, const uint8_t* data, size_t len)Decode one incoming replication packet. Returns false when it was refused — short header, unknown packet type, or a protocol / schema mismatch. The live path calls it from the NetworkManager filter; exposed so a headless driver can feed it hand-built packets.
OnIncomingPacket
bool OnIncomingPacket(const struct NetworkEvent& evt)The NetworkManager filter itself. Returns true when the event was a replication packet and was consumed; false leaves it in the game's queue, which is how a pre-auth ticket frame reaches the auth handler.
GetProtocolStats
const FProtocolStats& GetProtocolStats() constResetProtocolStats
void ResetProtocolStats()SetPeerByteBudgetPerSecond
void SetPeerByteBudgetPerSecond(uint32_t bytesPerSecond)Relevancy / interest management (UE NetCullDistance + NetPriority). ON by default (cvar net.relevancy). While OFF the server keeps the legacy behaviour: one Spawn broadcast per new object and one Snapshot per peer per tick with every peer seeing every object. That snapshot is capped by the same per-peer byte allowance and entry limit, and a cut sweep resumes where it stopped next tick: it used to send every changed object in one unbounded packet, which ENet fragmented past the MTU and lost whole on any dropped fragment. While ON the server keeps per-client bookkeeping: a client only gets the objects relevant to it (its own pawn, always-relevant objects, and distance-culled objects inside netCullDistance of its viewer). Entering relevancy sends that client a Spawn carrying the full pose and clears its per-client baseline, so the first snapshot entry it receives is a FULL field set rather than a delta against state it never had. Leaving relevancy sends a Destroy and drops the baseline. Per tick each client gets at most net.max_updates_per_tick entries and net.max_snapshot_bytes bytes, filled in descending netPriority * (1 + ticks-since-this-client-last-got-it) order. Staleness alone does NOT make starvation impossible: a 100x-priority object outranks a stale-by-10 neighbour for ~100 ticks. So anything that has waited net.starvation_ticks jumps AHEAD of the priority ordering entirely — a relevant object waits at most starvationTicks + relevantCount/budget ticks, whatever the priorities. Per-connection byte budget, on top of the per-tick entry/byte caps. Every byte the server hands a peer (spawns, destroys, reliable state and snapshots alike) is charged to that peer's one-second token bucket; the unreliable snapshot sweep is then capped by whatever is LEFT in it. Reliable traffic is never dropped — it just crowds the snapshot stream out for that tick, which is the behaviour a burst of spawns should have. 0 = unlimited.
GetPeerByteBudgetPerSecond
uint32_t GetPeerByteBudgetPerSecond() constGetPeerBytesSent
uint64_t GetPeerBytesSent(uint32_t peerId) constGetPeerByteTokens
uint32_t GetPeerByteTokens(uint32_t peerId) constGetPeerVoiceBytesCharged
uint64_t GetPeerVoiceBytesCharged(uint32_t peerId) constGetPeerBudgetDeferrals
uint32_t GetPeerBudgetDeferrals(uint32_t peerId) constGetTotalBytesSent
uint64_t GetTotalBytesSent() constSetPeerInboundByteBudgetPerSecond
void SetPeerInboundByteBudgetPerSecond(uint32_t bytesPerSecond)The same bucket in the other direction, and the one that was missing entirely. The RPC and input limiters count PACKETS, so they bound how often a peer may be heard and say nothing about how large each packet is: an RPC carries an arbitrary argument blob, and 32 of them a second at ENet's maximum fragment size is megabytes per second that the host decodes, dispatches and pays for before any policy runs. A byte bucket is the only limit that bounds the work. Charged on the SERVER only — a client throttling its own host would drop the world it is here for — and charged before the packet is decoded, because decoding is the cost. 0 = unlimited.
GetPeerInboundByteBudgetPerSecond
uint32_t GetPeerInboundByteBudgetPerSecond() constGetPeerBytesReceived
uint64_t GetPeerBytesReceived(uint32_t peerId) constGetPeerInboundByteTokens
uint32_t GetPeerInboundByteTokens(uint32_t peerId) constGetPeerInboundDrops
uint32_t GetPeerInboundDrops(uint32_t peerId) constServerAssignNetworkIds
void ServerAssignNetworkIds()Assign a NetworkId to every NetworkObjectComponent that lacks one and (relevancy off) broadcast its Spawn. The server tick does this itself; the session layer calls it right after spawning a player pawn so the pawn's id is resolvable before the join handshake goes out.
GetPeerIds
std::vector<uint32_t> GetPeerIds() constRegistered peer ids, in unspecified order.
FindNetworkIdByEntity
NetworkId FindNetworkIdByEntity(uint64_t entityId) constSession-local id of a replicated entity, or INVALID_NETWORK_ID.
SetRelevancyEnabled
void SetRelevancyEnabled(bool enabled)IsRelevancyEnabled
bool IsRelevancyEnabled() constSetMaxUpdatesPerTick
void SetMaxUpdatesPerTick(uint32_t maxUpdates)SetMaxSnapshotBytes
void SetMaxSnapshotBytes(uint32_t maxBytes)SetStarvationTicks
void SetStarvationTicks(uint32_t ticks)SetDefaultCullDistance
void SetDefaultCullDistance(float distance)GetDefaultCullDistance
float GetDefaultCullDistance() constGetMaxUpdatesPerTick
uint32_t GetMaxUpdatesPerTick() constGetMaxSnapshotBytes
uint32_t GetMaxSnapshotBytes() constGetReplicatedObjectCount
uint32_t GetReplicatedObjectCount() constGetPeerCount
uint32_t GetPeerCount() constGetSnapshotRateHz
float GetSnapshotRateHz() constRegisterPeer
void RegisterPeer(uint32_t peerId)The server tracks one relevancy state per connected client. Peers are registered automatically from the NetworkManager connect/disconnect hooks; the explicit calls exist for headless drivers and for games that fabricate peers (bots, spectators).
UnregisterPeer
void UnregisterPeer(uint32_t peerId)HasPeer
bool HasPeer(uint32_t peerId) constServerResyncPeer
void ServerResyncPeer(uint32_t peerId)ServerDetectOwnerChanges
void ServerDetectOwnerChanges()GetOwnerChangeResyncCount
uint32_t GetOwnerChangeResyncCount() constGetBlobChannel
FNetBlobChannel& GetBlobChannel()GetBlobChannel
const FNetBlobChannel& GetBlobChannel() constGetRpcBlobThreshold
uint32_t GetRpcBlobThreshold() constGetSpatialServer
FSpatialStreamServer& GetSpatialServer()The keyed delta stream (chunk edits and the like). The host publishes and each peer registered here is a stream client; a client applies through SetApplyFn and declares what it wants with ClientSetSpatialInterest.
GetSpatialClient
FSpatialStreamClient& GetSpatialClient()ClientSetSpatialInterest
void ClientSetSpatialInterest(const std::vector<FSpatialKey>& keysNearestFirst)RegisterFastArray
void RegisterFastArray(uint64_t entityId, uint16_t arrayId, FNetFastArrayBase* array, bool ownerOnly = false)Fast arrays (UE's FFastArraySerializer). Bind a list to a replicated entity under an id unique on that entity; the server then sends each relevant peer only the items that changed, on the reliable channel, and the client binding with the same (entity's ghost, id) applies them. ownerOnly limits the list to the entity's owning peer (inventory). The array must outlive its binding: unbind in the owner's teardown. A delta that reaches a client before its binding exists is held, in order, and applied when the binding appears.
UnregisterFastArray
void UnregisterFastArray(FNetFastArrayBase* array)GetFastArrayDeltasSent
uint32_t GetFastArrayDeltasSent() constGetFastArrayDeltasApplied
uint32_t GetFastArrayDeltasApplied() constSetPeerViewer
void SetPeerViewer(uint32_t peerId, const Vec3& position)Where the client "is". Either an explicit position or an entity whose TransformComponent is sampled at the start of every relevancy step (the client's pawn — the normal case).
SetPeerRelevancyGroups
void SetPeerRelevancyGroups(uint32_t peerId, uint32_t groups)Which NetworkObjectComponent::netRelevancyGroups this peer belongs to (all by default). A team switch is one call; objects that leave the peer's groups are destroyed on it at the next relevancy step.
GetPeerRelevancyGroups
uint32_t GetPeerRelevancyGroups(uint32_t peerId) constSetPeerViewEntity
void SetPeerViewEntity(uint32_t peerId, uint64_t entityId)IsRelevantTo
bool IsRelevantTo(uint32_t peerId, NetworkId nid) constTrue when nid is currently replicated to peerId (the client owns a ghost for it). Used by gameplay code that must not RPC an object the client can't see.
SetPacketSink
void SetPacketSink(FPacketSinkFn sink, void* context, FSlotReleaseFn release = nullptr)ClearPacketSink
void ClearPacketSink()SetPacketSink
template<typename F> void SetPacketSink(F&& fn)Convenience for a capturing callable. See MakeSlotContext — the holder and its destructor are instantiated HERE, in the caller's image.
ServerRelevancyStep
void ServerRelevancyStep(bool advanceTick = true)One relevancy pass: reap destroyed objects, then per client emit Spawn (entered) / Destroy (left) / Snapshot (budgeted). Public so it can be driven without a socket or a clock; a caller with no clock leaves advanceTick on so the tick and its lag-comp capture happen here. ServerTick passes false, since it already stepped the fixed tick.
ServerBroadcastSnapshot
void ServerBroadcastSnapshot()One non-relevancy snapshot pass: builds this tick's continuous (unreliable) + discrete (reliable) deltas and ships them to every registered peer, each stamped with that peer's ack. Public so it can be driven without a socket or a clock.
GetRelevancyStats
const FRelevancyStats& GetRelevancyStats() constSendRpcToAllClients
bool SendRpcToAllClients(NetworkId nid, uint16_t methodId, uint16_t methodIndex, const void* args, size_t argLen, NetworkChannel channel = NetworkChannel::Reliable)Manual routing: the caller picks the direction. methodId is the target component's id (or a session event id >= 0x8000); methodIndex is the position of the method in that component's reflected FunctionInfo table (0 for session events). The pair is what the authority policy keys on, so a client can be granted one method without opening its siblings. args are an opaque blob FRpcDispatcher marshals through MHT thunks. Server-only: SendRpcToAllClients(networkId, methodId, methodIndex, args) SendRpcToClient(networkId, peerId, methodId, methodIndex, args) Client-only: SendRpcToServer(networkId, methodId, methodIndex, args)
SendRpcToClient
bool SendRpcToClient(NetworkId nid, uint32_t peerId, uint16_t methodId, uint16_t methodIndex, const void* args, size_t argLen, NetworkChannel channel = NetworkChannel::Reliable)SendRpcToServer
bool SendRpcToServer(NetworkId nid, uint16_t methodId, uint16_t methodIndex, const void* args, size_t argLen, NetworkChannel channel = NetworkChannel::Reliable)SetRpcReceiver
bool SetRpcReceiver(FRpcReceiverFn r, void* context, FSlotReleaseFn release = nullptr, const char* ownerName = nullptr)ClearRpcReceiver
void ClearRpcReceiver()HasRpcReceiver
bool HasRpcReceiver() constGetRpcReceiverOwner
const char* GetRpcReceiverOwner() constSetRpcReceiver
template<typename F> bool SetRpcReceiver(F&& fn, const char* ownerName = nullptr)TakeRpcReceiver
void TakeRpcReceiver(FRpcReceiverFn r, void* context, FSlotReleaseFn release, const char* ownerName)Engine-level claim: takes the slot even when something else holds it, logging the displacement. FNetSession uses it — the session owns RPC routing for the whole process once it is running, and a game object that grabbed the slot earlier must not break the join handshake.
TakeRpcReceiver
template<typename F> void TakeRpcReceiver(F&& fn, const char* ownerName)AddRpcObserver
uint32_t AddRpcObserver(FRpcReceiverFn r, void* context, FSlotReleaseFn release = nullptr)AddRpcObserver
template<typename F> uint32_t AddRpcObserver(F&& fn)RemoveRpcObserver
void RemoveRpcObserver(uint32_t handle)ClearRpcObservers
void ClearRpcObservers()HasRpcObserver
bool HasRpcObserver(uint32_t handle) constTrue while the observer behind handle is still installed. A session teardown clears every observer underneath its installer; a long-lived system re-arms on the next tick instead of assuming its slot survived.
SetPeerAuthPredicate
void SetPeerAuthPredicate(FPeerAuthFn p, void* context, FSlotReleaseFn release = nullptr)ClearPeerAuthPredicate
void ClearPeerAuthPredicate()SetPeerAuthPredicate
template<typename F> void SetPeerAuthPredicate(F&& fn)SetRpcChannelClass
void SetRpcChannelClass(uint16_t componentId, uint16_t methodIndex, ENetRpcChannelClass channelClass)GetRpcChannelClass
ENetRpcChannelClass GetRpcChannelClass(uint16_t componentId, uint16_t methodIndex) constClearRpcChannelClasses
void ClearRpcChannelClasses()DefaultChannelForRpcClass
static NetworkChannel DefaultChannelForRpcClass(ENetRpcChannelClass channelClass)The channel a method of this class rides unless the caller names one.
AllowClientRpc
void AllowClientRpc(uint16_t componentId, uint16_t methodIndex, ENetRpcAuthority authority)DenyClientRpc
void DenyClientRpc(uint16_t componentId, uint16_t methodIndex)AllowClientRpcHighRate
void AllowClientRpcHighRate(uint16_t componentId, uint16_t methodIndex, ENetRpcAuthority authority)Allow-list and rate-class in one call — the shape a high-rate verb wants, so the two halves cannot drift apart at the call site.
AllowClientRpcComponent
void AllowClientRpcComponent(uint16_t componentId, ENetRpcAuthority authority)Component-wide grant — the pre-v3 blast radius, kept as an explicit convenience for a component whose every method shares one policy. It logs exactly which component it widened so the breadth is never silent, and a per-method AllowClientRpc still takes precedence over it.
DenyClientRpcComponent
void DenyClientRpcComponent(uint16_t componentId)ClearClientRpcPolicy
void ClearClientRpcPolicy()GetClientRpcAuthority
ENetRpcAuthority GetClientRpcAuthority(uint16_t componentId, uint16_t methodIndex) constInstallAnnotatedRpcPolicies
void InstallAnnotatedRpcPolicies()Walk every reflected component's MFUNCTION table and install the policy its RPC-direction annotations imply: a Server method becomes AllowClientRpc(component, index, OwnerOnly); Client / Multicast methods stay client-denied (they are server→client only). Idempotent — a subsequent explicit AllowClientRpc overrides the annotation default. Called from Initialize so a game that only annotates needs no policy call site; safe to call again after loading a game module.
SetRpcRateLimit
void SetRpcRateLimit(uint32_t packetsPerSecond)Per-peer token buckets over the two client→server paths a peer can flood (ENet is created with both bandwidth limits at zero, so nothing below us throttles). 0 = unlimited. Defaults come from the cvars net.rpc_rate_limit / net.input_rate_limit.
SetInputRateLimit
void SetInputRateLimit(uint32_t packetsPerSecond)SetHighRateRpcLimit
void SetHighRateRpcLimit(uint32_t packetsPerSecond)The HighRate bucket, charged only by methods registered SetRpcChannelClass(..., HighRate). Separate from the default bucket on purpose: a sweep at 200/s must pass while everything else stays at 32/s.
GetHighRateRpcLimit
uint32_t GetHighRateRpcLimit() constServerRefillRateLimits
void ServerRefillRateLimits(float deltaTime)Refill every peer's buckets. Called from ServerTick; public so a headless driver can advance the limiter without a clock.
GetRpcSecurityStats
const FRpcSecurityStats& GetRpcSecurityStats() constResetRpcSecurityStats
void ResetRpcSecurityStats()ServerHandleClientRpc
bool ServerHandleClientRpc(NetworkId nid, uint16_t methodId, uint16_t methodIndex, const uint8_t* args, size_t argLen, uint32_t senderPeerId)Server-side entry point for an incoming client→server RPC, policy included. The wire path calls it; exposed so tests can exercise the authority model without a socket. Returns false when the call was rejected (and the receiver was NOT invoked).
ServerApplyAck
void ServerApplyAck(uint32_t peerId, uint32_t packetId)Ack-driven delta baselines A peer's per-object baseline advances only when the packet carrying the new state is acknowledged. Until then the server keeps diffing against the last CONFIRMED state, so a dropped snapshot is re-sent on the next tick instead of being lost forever. Public so a headless driver can deliver (or deliberately drop) acks.
GetPeerLastAckedPacketId
uint32_t GetPeerLastAckedPacketId(uint32_t peerId) constSetMaxUnackedSends
void SetMaxUnackedSends(uint32_t sends)Bounding the resend Re-sending an unacked delta every tick is what repairs a dropped snapshot, and it is also unbounded: a peer that stops acking costs one entry per object per tick for as long as it stays connected. The two reasons a peer stops acking need different answers, so they are separated by how long the silence lasts rather than lumped together. Bad link, acks still arriving — silence shorter than net.max_unacked_sends packets. Nothing changes: the per-tick resend IS the repair, and cutting it short would strand the ghost. Gone away, no acks at all — silence past that threshold. The peer is marked ack-stalled and the per-object sweep stops for it entirely. Cost collapses from O(objects) every tick to one empty header every net.ack_probe_interval ticks, which is what makes the traffic stop climbing with object count. The probe exists so the peer can come back on its own: suppressing sends outright would mean it receives nothing, therefore acks nothing, therefore stays stalled forever. Recovery forces a FULL RESYNC rather than promoting pending baselines. Acks are cumulative, so an ack for the probe would otherwise confirm every packet lost during the stall and leave the server diffing against state the peer never received — the exact failure ack-driven baselines exist to prevent. Dropping the peer's baselines costs one full-state send and is correct by construction.
SetAckProbeInterval
void SetAckProbeInterval(uint32_t ticks)IsPeerAckStalled
bool IsPeerAckStalled(uint32_t peerId) constGetPeerUnackedSends
uint32_t GetPeerUnackedSends(uint32_t peerId) constClientSendAck
void ClientSendAck(uint32_t packetId)Client-side: send an Ack for the highest snapshot packetId seen. Called automatically from the incoming-packet path.
RecordClientInput
void RecordClientInput(uint32_t clientTick, const ReplicationInputBody& body)Client-side prediction The framework only provides bookkeeping — actual prediction logic is gameplay-specific and lives in user code (a script reads GetUnacknowledgedInputs, replays them against the entity's owned state, etc.). The pieces here are: - A ring buffer of locally-recorded inputs, keyed by clientTick. Scripts call RecordClientInput each tick on the client. The manager packs + sends to the server. - Last-acknowledged client tick — extracted from snapshot headers (server-side enhancement extends Snapshot packets with the most recent input it processed per peer; client uses that to discard buffered inputs and trigger reconciliation). - A reconcile callback invoked when a snapshot brings news that the server has advanced past inputs we already predicted — user code rewinds owned-entity state and replays the still- pending inputs.
RecordPredictedInput
void RecordPredictedInput(uint32_t clientTick, const ReplicationInputBody& body)Record a locally-predicted input into the pending ring WITHOUT shipping it (no transport / role gate). RecordClientInput = this + ship. Exposed for headless prediction drivers and tests.
ClientApplyServerAck
void ClientApplyServerAck(uint32_t lastProcessedInputTick)Client-side: a server→client packet carried a fresh per-peer last-processed-input tick. Retire acknowledged pending inputs and fire the reconcile callback (replay the still-unacked inputs from authoritative state). No-op if the ack didn't advance. Role-agnostic so tests can drive it; OnIncomingPacket calls it on every snapshot.
ServerRecordProcessedInput
void ServerRecordProcessedInput(uint32_t peerId, uint32_t clientTick)Server-side: remember the highest input tick processed for peerId. Stamped into every snapshot header sent to that peer. Called from the Input receive path; exposed for headless drivers and tests.
GetPeerLastProcessedInput
uint32_t GetPeerLastProcessedInput(uint32_t peerId) constTryGetAuthoritativeTransform
bool TryGetAuthoritativeTransform(NetworkId nid, TransformComponent& out) constLatest AUTHORITATIVE ghost pose the client has decoded for nid (the raw snapshot state, before interpolation). Reconcile callbacks snap the owned pawn to this before replaying pending inputs.
TryGetReplicatedNetState
bool TryGetReplicatedNetState(NetworkId nid, uint32_t& outNetState) constLatest decoded DISCRETE replicated state (netState) for a ghost — the value the reliable StateSnapshot stream converged to.
TryGetReplicatedComponent
const void* TryGetReplicatedComponent(NetworkId nid, const char* componentDisplayName) constLatest decoded bytes of any OTHER replicated component on a ghost, and the reflected field read off them. The shadow exists even when the ghost entity does not, so a headless client can assert convergence. Pointer to the client-side decoded mirror INSTANCE of a replicated component (a real constructed object — string members live in it), or null when nothing arrived for that ghost/component yet.
TryGetReplicatedField
bool TryGetReplicatedField(NetworkId nid, const char* componentDisplayName, const char* fieldName, void* out, size_t outSize) constGetLastAcknowledgedClientTick
uint32_t GetLastAcknowledgedClientTick() constGetClientTick
uint32_t GetClientTick() constGetPendingInputs
const std::vector<PendingInput>& GetPendingInputs() constSetReconcileCallback
void SetReconcileCallback(FReconcileFn c, void* context, FSlotReleaseFn release = nullptr)ClearReconcileCallback
void ClearReconcileCallback()SetReconcileCallback
template<typename F> void SetReconcileCallback(F&& fn)SetInputReceiver
void SetInputReceiver(FInputReceiverFn r, void* context, FSlotReleaseFn release = nullptr)ClearInputReceiver
void ClearInputReceiver()SetInputReceiver
template<typename F> void SetInputReceiver(F&& fn)SetInputAckDeferred
void SetInputAckDeferred(bool deferred)True for a receiver that only queues a move and simulates it later: the manager then leaves the ack to it (ServerRecordProcessedInput once the move has run), so the tick a client reconciles against names a state the server actually computed.
RewindTo
bool RewindTo(uint32_t serverTick)Lag compensation Server-side authoritative history. Each server tick the manager captures every NetworkObject's transform into a ring buffer keyed by serverTick. Hit-registration code calls RewindTo(serverTick) before its raycast / overlap query and RestorePresent() afterward — the manager applies the snapshot to live TransformComponents and then puts them back. NOT thread-safe; only meaningful on the server and only between physics ticks. The lag-comp window defaults to ~500ms of history (15 ticks at 30Hz) — covers realistic ping-plus-interpolation-delay budgets.
RestorePresent
void RestorePresent()SetLagCompHistoryTicks
void SetLagCompHistoryTicks(uint32_t ticks)