UActorChannel

A channel for exchanging actor and its subobject's properties and RPCs.

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Engine/ActorChannel.h

Include

#include "Engine/ActorChannel.h"

Syntax

class UActorChannel : public UChannel

Remarks

A channel for exchanging actor and its subobject's properties and RPCs.

ActorChannel manages the creation and lifetime of a replicated actor. Actual replication of properties and RPCs actually happens in FObjectReplicator now (see DataReplication.h).

An ActorChannel bunch looks like this:

+-------------------+------------------------------------------------------------------------+ | SpawnInfo | (Spawn Info) Initial bunch only | | -Actor Class | -Created by ActorChannel | | -Spawn Loc/Rot | | | NetGUID assigns | | | -Actor NetGUID | | | -Component NetGUIDs | | +-------------------+------------------------------------------------------------------------+ | | | +-------------------+------------------------------------------------------------------------+ | NetGUID ObjRef | (Content chunks) x number of replicating objects (Actor + any components) | | | -Each chunk created by its own FObjectReplicator instance. | +-------------------+------------------------------------------------------------------------+ | | |

Properties...

RPCs...

+-------------------+------------------------------------------------------------------------+ | </End> | | +-------------------+------------------------------------------------------------------------+

Variables

Name Description

Public variable

TObjectPtr< AAc...

 

Actor

Variables.

Public variable

FNetworkGUID

 

ActorNetGUID

Public variable

TSharedPtr< FOb...

 

ActorReplicator

Public variable

uint32: 1

 

bBlockChannelFailure

Whether or not to block sending of NMT_ActorChannelFailure (for NetcodeUnitTest)

Public variable

uint32: 1

 

bClearRecentActorRefs

Whether we should nullptr references to this channel's Actor in other channels' Recent data when this channel is closed set to false in cases where the Actor can't become relevant again (e.g. destruction) as it's unnecessary in that case

Public variable

uint32: 1

 

bForceCompareProperties

Public variable

uint32: 1

 

bHoldQueuedExportBunchesAndGUIDs

Public variable

uint32: 1

 

bIsReplicatingActor

Public variable

float

 

CustomTimeDilation

Public variable

double

 

LastUpdateTime

Public variable

TSet< FNetworkG...

 

PendingGuidResolves

Public variable

TArray< class F...

 

QueuedBunches

Async networking loading support state.

Public variable

double

 

QueuedBunchStartTime

Public variable

EChannelCloseRe...

 

QueuedCloseReason

Public variable

TArray< class F...

 

QueuedExportBunches

Public variable

TArray< FNetwor...

 

QueuedMustBeMappedGuidsInLastBunch

Public variable

double

 

RelevantTime

Variables.

Public variable

TMap< UObject &...

 

ReplicationMap

Public variable

uint32: 1

 

SpawnAcked

Constructors

Name Description

Public function

UActorChannel

(
    const FObjectInitializer& ObjectIn...
)

Default constructor

Destructors

Name Description

Public function

~UActorChannel()

Functions

Name Description

Public function Static

void

 

AddReferencedObjects

(
    UObject* InThis,
    FReferenceCollector& Collector
)

Public function

void

 

BreakAndReleaseReferences()

Release any references this channel is holding to UObjects and object replicators and mark it as broken.

Public function Static

bool

 

CanIgnoreDeprecatedReplicateSubObjects()

Only returns true when calling ReplicateSubobjects() while we are trying to detect bad usage of the legacy function.

Public function

void

 

CleanupReplicators

(
    const bool bKeepReplicators
)

Cleans up replicators and clears references to the actor class this channel was associated with.

Protected function

TSharedRef< ...

 

CreateReplicator

(
    UObject* Obj
)

Creates a new object replicator or reuses a replicator if it was stored for dormancy in the Connection.

Protected function

void

 

DestroyActorAndComponents()

Protected function

bool

 

DoSubObjectReplication

(
    FOutBunch& Bunch,
    FReplicationFlags& OutRepFlags
)

Handle the replication of subobjects for this actor.

Protected function

TSharedRef< ...

 

FindOrCreateReplicator

(
    UObject* Obj,
    bool* bOutCreated
)

Convenience method for finding a replicator, and creating one if necessary, all at once.

Protected function

TSharedRef< ...

 

FindReplicator

(
    UObject* Obj
)

Attempts to find a valid, non-dormant replicator for the given object.

Public function Const

AActor *

 

GetActor()

UActorChannel interface and accessors.

Public function

FObjectRepli...

 

GetActorReplicationData()

Returns the replicator for the actor associated with this channel. Guaranteed to exist.

Public function Const

const TArray...

 

GetCreatedSubObjects()

Public function

FNetFieldExp...

 

GetNetFieldExportGroupForClassNetCache

(
    UClass* ObjectClass
)

Finds the net field export group for a class net cache, if not found, creates one

Public function

FNetFieldExp...

 

GetOrCreateNetFieldExportGroupForClassNetCache

(
    const UObject* Object
)

Finds (or creates) the net field export group for a class net cache, if not found, creates one

Public function Const

bool

 

GetSkipRoleSwap()

Public function Const

bool

 

IsActorReadyForReplication()

Tells if the actor is ready to be replicated since he is BeginPlay or inside BeginPlay

Protected function

void

 

MoveMappedObjectToUnmapped

(
    const UObject* Object
)

Unmap all references to this object, so that if later we receive this object again, we can remap the original references

Public function Virtual

void

 

NotifyActorChannelOpen

(
    AActor* InActor,
    FInBunch& InBunch
)

Protected function Const

bool

 

ObjectHasReplicator

(
    const TWeakObjectPtr< UObject >& O...
)

Public function

void

 

PrepareForRemoteFunction

(
    UObject* TargetObj
)

If not queueing the RPC, prepare the channel for replicating the call.

Public function

void

 

ProcessBunch

(
    FInBunch& Bunch
)

Public function

bool

 

ProcessQueuedBunches()

Public function

void

 

QueueRemoteFunctionBunch

(
    UObject* CallTarget,
    UFunction* Func,
    FOutBunch& Bunch
)

Queue a function bunch for this channel to be sent on the next property update.

Public function

UObject *...

 

ReadContentBlockHeader

(
    FInBunch& Bunch,
    bool& bObjectDeleted,
    bool& bOutHasRepLayout
)

Reads the header of the content block and instantiates the subobject if necessary

Public function

UObject *...

 

ReadContentBlockPayload

(
    FInBunch& Bunch,
    FNetBitReader& OutPayload,
    bool& bOutHasRepLayout
)

Reads content block header and payload

Public function Const

bool

 

ReadFieldHeaderAndPayload

(
    UObject* Object,
    const FClassNetCache* ClassCac...,
    FNetFieldExportGroup* NetField...,
    FNetBitReader& Bunch,
    const FFieldNetCache** Out...,
    FNetBitReader& OutPayload
)

Reads property/function header and data blob from network stream

Public function

void

 

ReleaseReferences

(
    bool bKeepReplicators
)

Public function

int64

 

ReplicateActor()

Replicate this channel's actor differences.

Public function

bool

 

ReplicateSubobject

(
    UActorComponent* ActorChannel,
    FOutBunch& Bunch,
    FReplicationFlags RepFlags
)

Replicates an ActorComponent subobject.

Public function

bool

 

ReplicateSubobject

(
    UObject* Obj,
    FOutBunch& Bunch,
    FReplicationFlags RepFlags
)

Replicates given subobject on this actor channel

Public function Virtual

bool

 

ReplicateSubobjectCustom

(
    UObject* Obj,
    FOutBunch& Bunch,
    const FReplicationFlags& RepFlags
)

Custom implementation for ReplicateSubobject when RepFlags.bUseCustomSubobjectReplication is true

Public function

void

 

SetChannelActor

(
    AActor* InActor,
    ESetChannelActorFlags Flags
)

Set this channel's actor to the given actor.

Public function Static

void

 

SetCurrentSubObjectOwner

(
    UActorComponent* SubObjectOwne...
)

Subobject Replication state

Public function Static

void

 

SetCurrentSubObjectOwner

(
    AActor* SubObjectOwner
)

Subobject Replication state

Public function

void

 

SetForcedSerializeFromRPC

(
    bool bInFromRPC
)

Public function

void

 

SetSkipRoleSwap

(
    const bool bShouldSkip
)

Protected function

const TCHAR ...

 

ToString

Protected function

void

 

WriteContentBlockForSubObjectDelete

(
    FOutBunch& Bunch,
    FNetworkGUID& GuidToDelete,
    ESubObjectDeleteFlag DeleteFlag
)

Writes the header for a content block specifically for deleting sub-objects

Public function

void

 

WriteContentBlockHeader

(
    UObject* Obj,
    FNetBitWriter& Bunch,
    const bool bHasRepLayout
)

Writes the header for a content block of properties / RPCs for the given object (either the actor a subobject of the actor)

Public function

int32

 

WriteContentBlockPayload

(
    UObject* Obj,
    FNetBitWriter& Bunch,
    const bool bHasRepLayout,
    FNetBitWriter& Payload
)

Writes header and payload of content block

Public function

int32

 

WriteFieldHeaderAndPayload

(
    FNetBitWriter& Bunch,
    const FClassNetCache* ClassCac...,
    const FFieldNetCache* FieldCac...,
    FNetFieldExportGroup* NetField...,
    FNetBitWriter& Payload,
    bool bIgnoreInternalAck
)

Writes property/function header and data blob to network stream

Overridden from UChannel

Name Description

Public function Virtual

void

 

AddedToChannelPool()

Notification that this channel has been placed in a channel pool and needs to reset to its original state so it can be used again like a new channel

Public function Virtual

void

 

AppendExportBunches

(
    TArray< FOutBunch* >& OutExpo...
)

Append any export bunches

Public function Virtual

void

 

AppendMustBeMappedGuids

(
    FOutBunch* Bunch
)

Append any "must be mapped" guids to front of bunch.

Protected function Virtual

void

 

BecomeDormant()

Closes the actor channel but with a 'dormant' flag set so it can be reopened

Public function Virtual Const

bool

 

CanStopTicking()

Return true to indicate that this channel no longer needs to Tick() every frame.

Protected function Virtual

bool

 

CleanUp

(
    const bool bForDestroy,
    EChannelCloseReason CloseReason
)

Cleans up channel structures and nulls references to the channel

Public function Virtual

int64

 

Close

(
    EChannelCloseReason Reason
)

Close the base channel. Returns how many bits were written to the send buffer

Public function Virtual

FString

 

Describe()

Describe the channel.

Public function Virtual

void

 

Init

(
    UNetConnection* InConnection,
    int32 InChIndex,
    EChannelCreateFlags CreateFlags
)

UChannel interface.

Public function Virtual

bool

 

ReadyForDormancy

(
    bool debug
)

Returns true if channel is ready to go dormant (e.g., all outstanding property updates have been ACK'd)

Public function Virtual

void

 

ReceivedBunch

(
    FInBunch& Bunch
)

Handle an incoming bunch.

Public function Virtual

void

 

ReceivedNak

(
    int32 NakPacketId
)

Negative acknowledgment processing.

Public function Virtual

void

 

SetClosingFlag()

Set the closing flag.

Public function Virtual

void

 

StartBecomingDormant()

Puts the channel in a state to start becoming dormant.

Public function Virtual

void

 

Tick()

Handle time passing on this channel.

Overridden from UObject

Name Description

Public function Virtual

void

 

Serialize

(
    FArchive& Ar
)

Handles reading, writing, and reference collecting using FArchive.

Enums

Name

Description

Protected enum

ESubObjectDeleteFlag

Constants

Name

Description

ClassNetCacheSuffix

Deprecated Variables

Name Description

Public variable

TArray< TObject...

 

CreateSubObjects

The CreateSubObjects array will be made private in future versions. Use GetCreatedSubObjects() instead

Deprecated Functions

Name Description

Protected function

TSharedRef< ...

 

CreateReplicator

(
    UObject* Obj,
    bool bCheckDormantReplicators
)

This function has been deprecated in favor of the one with a single parameter

Protected function

TSharedRef< ...

 

FindReplicator

(
    UObject* Obj,
    bool* bOutFoundInvalid
)

This function has been deprecated in favor of the one with a single parameter

Public function

bool

 

ReplicateSubobjectList

(
    TArray< Type* >& ObjectList,
    FOutBunch& Bunch,
    const FReplicationFlags& RepFlags
)

This function will be deleted. Register your subobjects using AddReplicatedSubObject instead.

Public function

void

 

WriteContentBlockForSubObjectDelete

(
    FOutBunch& Bunch,
    FNetworkGUID& GuidToDelete
)

This function will be made private in the future.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Cancel