![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <DataReplication.h>
Classes | |
| struct | FRPCCallInfo |
| struct | FRPCPendingLocalCall |
Public Types | |
| enum class | ESkipRpcBehavior { NeverSkip , SkipIfNotReady , AlwaysSkip } |
Represents an object that is currently being replicated or handling RPCs.
|----------------|
| NetGUID ObjRef |
|----------------|
| |
| Properties... |
| |
| RPCs... |
| |
|----------------|
| </End Tag> |
|----------------|
|
strong |
| FObjectReplicator::FObjectReplicator | ( | ) |
| FObjectReplicator::~FObjectReplicator | ( | ) |
| bool FObjectReplicator::CanSkipUpdate | ( | FReplicationFlags | Flags | ) |
| void FObjectReplicator::CleanUp | ( | ) |
| void FObjectReplicator::ExecutePendingTransactionalRPCs | ( | ) |
Execute any pending RPCs meant to be done within an AutoRTFM transaction.
| void FObjectReplicator::ForceRefreshUnreliableProperties | ( | ) |
|
inline |
|
inline |
Recent/dirty related functions
Utility function to make a copy of the net properties
| Source | - Memory to copy initial state from |
| void FObjectReplicator::InitWithObject | ( | UObject * | InObject, |
| UNetConnection * | InConnection, | ||
| bool | bUseDefaultState = true |
||
| ) |
|
inline |
| bool FObjectReplicator::MoveMappedObjectToUnmapped | ( | const FNetworkGUID & | GUID | ) |
|
inline |
| void FObjectReplicator::PostReceivedBunch | ( | ) |
| void FObjectReplicator::PostSendBunch | ( | FPacketIdRange & | PacketRange, |
| uint8 | bReliable | ||
| ) |
|
inline |
| void FObjectReplicator::QueuePropertyRepNotify | ( | UObject * | Object, |
| FProperty * | Property, | ||
| const int32 | ElementIndex, | ||
| TArray< uint8 > & | MetaData | ||
| ) |
| bool FObjectReplicator::ReceivedBunch | ( | FNetBitReader & | Bunch, |
| const FReplicationFlags & | RepFlags, | ||
| const bool | bHasRepLayout, | ||
| bool & | bOutHasUnmapped | ||
| ) |
Packet was dropped
Handling NAKs / Property Retransmission.
Note, NACK handling only occurs on connections that "replicate" data, which is currently only Servers. RPC retransmission is handled elsewhere.
RepLayouts:
As we send properties through FRepLayout the is a Changelist Manager that is shared between all connections tracks sets of properties that were recently changed (history items), as well as one aggregate set of all properties that have ever been sent. Each Sending Rep State, which is connection unique, also tracks the set of changed properties. These history items will only be created when replicating the object, so there will be fewer of them in general, but they will still contain any properties that compared differently (not *just* the properties that were actually replicated). Whenever a NAK is received, we will iterate over the SendingRepState changelist and mark any of the properties sent in the NAKed packet for retransmission. The next time Properties are replicated for the Object, we will merge in any changelists from NAKed history items.
Custom Delta Properties:
For Custom Delta Properties (CDP), we rely primarily on FPropertyRetirements and INetDeltaBaseState for tracking property retransmission. INetDeltaBaseStates are used to tracked internal state specific to a given type of CDP. For example, Fast Array Replicators will use FNetFastTArrayBaseState, or some type derived from that. When an FObjectReplicator is created, we will create an INetDeltaBaseState for every CDP, as well as a dummy FPropertyRetirement. This Property Retirement is used as the head of a linked list of Retirements, and is generally never populated with any useful information. Every time we replicate a CDP, we will pass in the most recent Base State, and we will be returned a new CDP. If data is actually sent, then we will create a new Property Retirement, adding it as the tail of our linked list. The new Property Retirement will also hold a reference to the old INetDeltaBaseState (i.e., the state of the CDP before it replicated its properties). Just before replicating, we will go through and free any ACKed FPropertyRetirments (see UpdateAckedRetirements). After replicating, we will cache off the returned Base State to be used as the "old" state the next time the property is replicated. Whenever a NAK is received, we will run through our Property Retirements. Any retirements that predate the NACK will be removed and treated as if they were ACKs. The first retirement that is found to be within the NAKed range will have its INetDeltaBaseState restored (which should be the state before the NAKed packet was sent), and then that retirement as well as all remaining will be removed. The onus is then on the CDP to resend any necessary properties based on its current / live state and the restored Net Delta Base State.
Fast Array Properties:
Fast Array Properties are implemented as Custom Delta Properties (CDP). Therefore, they mostly follow the flow laid out above. FNetFastTArrayBaseState is the basis for all Fast Array Serializer INetDeltaBaseStates. This struct tracks the Replication Key of the Array, the ID to Replication Key map of individual Array Items, and a History Number. As we replicate Fast Array Properties, we use the Array Replication key to see if anything is possibly dirty in the Array and the ID to Replication map to see which Array Element items actually are dirty. A mismatch between the Net Base State Key and the Key stored on the live Fast Array (either the Array Replication Key, or any Item Key) is how we determine if the Array or Items is dirty. Whenever a NAK is received, our Old Base State will be reset to the last known ACKed value, as described in the CDP section above. This means that our Array Replication Key and ID To Item Replication Key should be reset to those states, forcing a mismatch the next time we replicate if anything has changed. When net.SupportFastArrayDelta is enabled, we perform an additional step in which we actually compare the properties of dirty items. This is very similar to normal Property replication using RepLayouts, and leverages most of the same code. This includes tracking history items just like Rep Layout. Instead of tracking histories per Sending Rep State / Per Connection, we just manage a single set of Histories on the Rep Changelist Mgr. Changelists are stored per Fast Array Item, and are referenced via ID. Whenever we go to replicate a Fast Array Item, we will merge together all changelists since we last sent that item, and send those accumulated changes. This means that property retransmission for Fast Array Items is an amalgamation of Rep Layout retransmission and CDP retransmission. Whenever a NAK is received, our History Number should be reset to the last known ACKed value, and that should be enough to force us to accumulate any of the NAKed item changelists.
|
inline |
| bool FObjectReplicator::ReceivedRPC | ( | FNetBitReader & | Reader, |
| TSet< FNetworkGUID > & | OutUnmappedGuids, | ||
| bool & | bOutSkippedRpcExec, | ||
| const FReplicationFlags & | RepFlags, | ||
| const FFieldNetCache * | FieldCache, | ||
| ESkipRpcBehavior | SkipRpcBehavior | ||
| ) |
| Reader | the buffer that contains the RPC (this function reads RPC parameters from the current position) |
| OutUnmappedGuids | any GUIDs that are not yet resolvable because we do not have the data (yet) |
| bOutSkippedRpcExec | did we skip execution of this RPC? If so, the caller must handle execution (e.g. delay). |
| RepFlags | the replication flags (state) of the replicated object |
| FieldCache | the RPC FieldCache used to speed-up property lookups. This cannot be null. |
| SkipRpcBehavior | under what circumstances should we skip the execution of the RPC? |
|
inline |
| void FObjectReplicator::ReplicateCustomDeltaProperties | ( | FNetBitWriter & | Bunch, |
| FReplicationFlags | RepFlags, | ||
| bool & | bSkippedPropertyCondition | ||
| ) |
| bool FObjectReplicator::ReplicateProperties | ( | FOutBunch & | Bunch, |
| FReplicationFlags | RepFlags | ||
| ) |
| bool FObjectReplicator::ReplicateProperties | ( | FOutBunch & | Bunch, |
| FReplicationFlags | RepFlags, | ||
| FNetBitWriter & | Writer | ||
| ) |
| bool FObjectReplicator::ReplicateProperties_r | ( | FOutBunch & | Bunch, |
| FReplicationFlags | RepFlags, | ||
| FNetBitWriter & | Writer | ||
| ) |
Replicates properties to the Bunch. Returns true if it wrote anything
|
inline |
| bool FObjectReplicator::SendCustomDeltaProperty | ( | UObject * | InObject, |
| uint16 | CustomDeltaProperty, | ||
| FNetBitWriter & | OutBunch, | ||
| TSharedPtr< INetDeltaBaseState > & | NewFullState, | ||
| TSharedPtr< INetDeltaBaseState > & | OldState | ||
| ) |
| void FObjectReplicator::StartBecomingDormant | ( | ) |
| void FObjectReplicator::StartReplicating | ( | class UActorChannel * | InActorChannel | ) |
| void FObjectReplicator::StopReplicating | ( | class UActorChannel * | InActorChannel | ) |
| void FObjectReplicator::UpdateGuidToReplicatorMap | ( | ) |
Takes Data, and compares against shadow state to log differences
| void FObjectReplicator::WritePropertyHeaderAndPayload | ( | UObject * | Object, |
| FProperty * | Property, | ||
| FNetFieldExportGroup * | NetFieldExportGroup, | ||
| FNetBitWriter & | Bunch, | ||
| FNetBitWriter & | Payload | ||
| ) | const |
| uint32 FObjectReplicator::bForceUpdateUnmapped |
True if we need to do an unmapped check next frame.
| uint32 FObjectReplicator::bHasReplicatedProperties |
Whether or not we've already replicated properties this frame.
| uint32 FObjectReplicator::bLastUpdateEmpty |
True if last update (ReplicateActor) produced no replicated properties
| uint32 FObjectReplicator::bOpenAckCalled |
Whether or not the Actor Channel on which we're replicating has been Opened / Acked by the receiver.
| uint32 FObjectReplicator::bSentSubObjectCreation |
Is this a subobject replicator and have we sent the creation data yet.
| TSharedPtr<class FReplicationChangelistMgr> FObjectReplicator::ChangelistMgr |
| TUniquePtr<FRepState> FObjectReplicator::CheckpointRepState |
| UNetConnection* FObjectReplicator::Connection |
Connection this replicator was created on.
| TObjectPtr<UClass> FObjectReplicator::ObjectClass |
| FNetworkGUID FObjectReplicator::ObjectNetGUID |
Net GUID for the object we're replicating.
| UObject* FObjectReplicator::ObjectPtr |
| class UActorChannel* FObjectReplicator::OwningChannel |
The Actor Channel that we're replicating on. This expected to be owned by Connection.
| TArray<FRPCPendingLocalCall> FObjectReplicator::PendingLocalRPCs |
Information on RPCs that have been received but not yet executed
| TSet<FNetworkGUID> FObjectReplicator::ReferencedGuids |
| TArray<FRPCCallInfo> FObjectReplicator::RemoteFuncInfo |
Meta information on pending net RPCs (to be sent)
| FOutBunch* FObjectReplicator::RemoteFunctions |
| TSharedPtr<FRepLayout> FObjectReplicator::RepLayout |
| TUniquePtr<FRepState> FObjectReplicator::RepState |
| int32 FObjectReplicator::TrackedGuidMemoryBytes |
The amount of memory (in bytes) that we're using to track Unmapped GUIDs.