UNetConnection

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Engine/NetConnection.h

Include

#include "Engine/NetConnection.h"

Syntax

class UNetConnection : public UPlayer

Variables

Name Description

Public variable

bool

 

AllowMerge

Public variable

FNetConnAnalyticsVars

 

AnalyticsVars

Net Analytics The locally cached/updated analytics variables, for the NetConnection - aggregated upon connection Close

Public variable

double

 

AverageFrameTime

Public variable

float

 

AvgLag

Public variable

float

 

BestLag

Public variable

double

 

BestLagAcc

Public variable

bool

 

bLastHasServerFrameTime

Public variable

bool

 

bNeedsByteSwapping

Whether this channel needs to byte swap all data or not

Public variable

uint32: 1

 

bPendingDestroy

Public variable

FString

 

Challenge

Public variable

TArray< UChannel * >

 

Channels

Public variable

TArray< class UChildConnection * >

 

Children

Child connections for secondary viewports

Public variable

EClientLoginState::Type

 

ClientLoginState

Login state tracking.

Public variable

FString

 

ClientResponse

Public variable

TSet< FName >

 

ClientVisibleLevelNames

On the server, the package names of streaming levels that the client has told us it has made visible the server will only replicate references to Actors in visible levels so that it's impossible to send references to Actors the client has not initialized

Public variable

float

 

ConnectTime

Time when connection request was first initiated

Public variable

int32

 

CountedFrames

Public variable

double

 

CumulativeTime

Public variable

TMap< UObject *, TSharedRef< FObjectReplicator > >

 

DormantReplicatorMap

A list of replicators that belong to recently dormant actors/objects

Public variable

UNetDriver *

 

Driver

Owning net driver

Public variable

uint32

 

EngineNetworkProtocolVersion

Network version.

Public variable

uint8

 

ExpectedClientLoginMsgType

Public variable

double

 

FrameTime

Public variable

uint32

 

GameNetworkProtocolVersion

Public variable

TUniquePtr< PacketHandler >

 

Handler

PacketHandler, for managing layered handler components, which modify packets as they are sent/received

Public variable

int32

 

InBytes

Bytes sent/received on this connection (accumulated during a StatPeriod)

Public variable

int32

 

InBytesPerSecond

Bytes sent/received on this connection (per second) - these are from previous StatPeriod interval

Public variable

int32

 

InitInReliable

Public variable

int32

 

InitOutReliable

Public variable

int32

 

InPacketId

Public variable

int32

 

InPackets

Packets sent/received on this connection (accumulated during a StatPeriod)

Public variable

int32

 

InPacketsLost

Packets lost on this connection (accumulated during a StatPeriod)

Public variable

int32

 

InPacketsPerSecond

Packets sent/received on this connection (per second) - these are from previous StatPeriod interval

Public variable

TArray< int32 >

 

InReliable

Public variable

uint32: 1

 

InternalAck

Public variable

int32

 

InTotalBytes

Total bytes sent/received on this connection

Public variable

int32

 

InTotalPackets

Total packets sent/received on this connection

Public variable

int32

 

InTotalPacketsLost

Total packets lost on this connection

Public variable

TMap< FNetworkGUID, TArray< class UActorChannel * > >

 

KeepProcessingActorChannelBunchesMap

This holds a list of actor channels that want to fully shutdown, but need to continue processing bunches before doing so

Public variable

double

 

LagAcc

Stat accumulators.

Public variable

int32

 

LagCount

Public variable

FBitWriterMark

 

LastEnd

Public variable

double

 

LastGoodPacketRealtime

Public variable

FOutBunch

 

LastOut

Public variable

FOutBunch *

 

LastOutBunch

Public variable

uint32

 

LastProcessedFrame

Public variable

double

 

LastReceiveRealtime

Public variable

double

 

LastReceiveTime

Internal.

Public variable

float

 

LastRecvAckTime

The last time an ack was received

Public variable

double

 

LastSendTime

Public variable

FBitWriterMark

 

LastStart

Merge info.

Public variable

double

 

LastTickTime

Public variable

double

 

LastTime

Public variable

int32

 

LogCallCount

Public variable

double

 

LogCallLastTime

Log tracking.

Public variable

int32

 

LogSustainedCount

Public variable

FOnLowLevelSend

 

LowLevelSendDel

Delegate for hooking LowLevelSend

Public variable

int32

 

MaxChannelSize

Public variable

int32

 

MaxPacket

Public variable

int32

 

MaxPacketHandlerBits

The maximum number of bits all packet handlers will reserve

Public variable

TNetAnalyticsDataPtr< FNetConnAnalyticsData >

 

NetAnalyticsData

The net analytics data holder for the NetConnection analytics, which is where analytics variables are aggregated upon Close

Public variable

int

 

NumAckBits

Number of bits used for acks in the current packet.

Public variable

int

 

NumBunchBits

Number of bits used for bunches in the current packet.

Public variable

int

 

NumPacketIdBits

Number of bits used for the packet id in the current packet.

Public variable

int

 

NumPaddingBits

Number of bits used for padding in the current packet.

Public variable

TArray< class UChannel * >

 

OpenChannels

Public variable

int32

 

OutAckPacketId

Public variable

int32

 

OutBytes

Public variable

int32

 

OutBytesPerSecond

Public variable

uint8[256]

 

OutBytesPerSecondHistory

Public variable

int32[256]

 

OutLagPacketId

Public variable

double[256]

 

OutLagTime

Public variable

int32

 

OutPacketId

Public variable

int32

 

OutPackets

Public variable

int32

 

OutPacketsLost

Public variable

int32

 

OutPacketsPerSecond

Public variable

TArray< int32 >

 

OutReliable

Public variable

int32

 

OutTotalAcks

Total acks sent on this connection

Public variable

int32

 

OutTotalBytes

Public variable

int32

 

OutTotalPackets

Public variable

int32

 

OutTotalPacketsLost

Public variable

AActor *

 

OwningActor

Reference to controlling actor (usually PlayerController)

Public variable

UPackageMap *

 

PackageMap

Package map between local and remote. (negotiates net serialization)

Public variable

TSubclassOf< UPackageMap >

 

PackageMapClass

The class name for the PackageMap to be loaded

Public variable

int32

 

PacketOverhead

Negotiated parameters.

Public variable

FPacketSimulationSettings

 

PacketSimulationSettings

Packet settings for testing lag, net errors, etc

Public variable

TArray< int32 >

 

PendingOutRec

Public variable

FUniqueNetIdRepl

 

PlayerId

Net id of remote player on this connection. Only valid on client connections (server side).

Public variable

int32

 

QueuedBits

Public variable

FOnReceivedRawPacket

 

ReceivedRawPacketDel

Delegate for hooking ReceivedRawPacket

Public variable

TSharedPtr< FInternetAddr >

 

RemoteAddr

The remote address of this connection, typically generated from the URL.

Public variable

float

 

RemoteSaturation

Public variable

FString

 

RequestURL

Public variable

EResendAllDataState

 

ResendAllDataState

This functionality is used during replay checkpoints for example, so we can re-use the existing connection and channels to record a version of each actor and capture all properties that have changed since the actor has been alive...

Public variable

int32

 

ResponseId

Public variable

FBitWriter

 

SendBuffer

Packet.

Public variable

FBitWriter

 

SendBunchHeader

The singleton buffer for sending bunch header information

Public variable

TArray< class AActor * >

 

SentTemporaries

This actor is bNetTemporary, which means it should never be replicated after it's initial packet is complete

Public variable

EConnectionState

 

State

Public variable

TWeakPtr< StatelessConnectHandlerComponent >

 

StatelessConnectComponent

Reference to the PacketHandler component, for managing stateless connection handshakes

Public variable

float

 

StatPeriod

Interval between gathering stats

Public variable

double

 

StatUpdateTime

Stat display.

Public variable

int32

 

TickCount

Public variable

bool

 

TimeSensitive

Public variable

FURL

 

URL

Public variable

AActor *

 

ViewTarget

The actor that is currently being viewed/controlled by the owning controller

Constructors

Name Description

Public function

UNetConnection

(
    const FObjectInitializer& ObjectInitializer
)

Public function

UNetConnection

(
    const FObjectInitializer& ObjectInitializer
)

Constructors and destructors.

Functions

Name Description

Public function Const

FActorChannelMap::TConstIterator

 

ActorChannelConstIterator()

Public function Const

const FActorChannelMap &

 

ActorChannelMap()

Public function Const

int32

 

ActorChannelsNum()

Public function

void

 

AddActorChannel

(
    AActor* Actor,
    UActorChannel* Channel
)

Public function

void

 

AddDestructionInfo

(
    FActorDestructionInfo* DestructionInfo
)

Public function Static

void

 

AddReferencedObjects

(
    UObject* InThis,
    FReferenceCollector& Collector
)

Public function Virtual

void

 

AssertValid()

Make sure this connection is in a reasonable state.

Public function Virtual

void

 

CleanUp()

Closes the control channel, cleans up structures, and prepares for deletion

Protected function

void

 

CleanupDormantActorState()

Public function

void

 

CleanupDormantReplicatorsForActor

(
    AActor* Actor
)

Removes Actor and its replicated components from DormantReplicatorMap.

Public function

void

 

CleanupStaleDormantReplicators()

Removes stale entries from DormantReplicatorMap.

Public function Virtual Const

bool

 

ClientHasInitializedLevelFor

(
    const AActor* TestActor
)

Returns whether the client has initialized the level required for the given object

Public function

void

 

Close()

Closes the connection (including sending a close notify across the network)

Public function

void

 

ConsumePacketAnalytics

Returns the current packet stability analytics and resets them.

Public function

void

 

ConsumeQueuedActorDelinquencyAnalytics

Returns the current delinquency analytics and resets them.

Public function

void

 

ConsumeSaturationAnalytics

Returns the current saturation analytics and resets them.

Public function

bool

 

ContainsActorChannel

(
    const TWeakObjectPtr< AActor >& Actor
)

Public function

UChannel *

 

CreateChannelByName

(
    const FName& ChName,
    EChannelCreateFlags CreateFlags,
    int32 ChannelIndex
)

Create a channel.

Public function Virtual

TSharedPtr< FObjectReplicator >

 

CreateReplicatorForNewActorChannel

(
    UObject* Object
)

Called by UActorChannel.

Public function Virtual

FString

 

Describe()

Describe the connection.

Protected function Virtual

void

 

DestroyIgnoredActor

(
    AActor* Actor
)

Called internally to destroy an actor during replay fast-forward when the actor channel index will be recycled

Public function

void

 

EnableEncryption

(
    const FEncryptionData& EncryptionData
)

Sets the encryption data and enables encryption.

Public function

void

 

EnableEncryption()

Enables encryption for the underlying encryption packet handler component.

Public function

void

 

EnableEncryptionServer

(
    const FEncryptionData& EncryptionData
)

Sets the encryption data, enables encryption, and sends the encryption ack to the client.

Public function

UActorChannel **

 

FindActorChannel

(
    const TWeakObjectPtr< AActor >& Actor
)

Public function

UActorChannel *

 

FindActorChannelRef

(
    const TWeakObjectPtr< AActor >& Actor
)

Public function Virtual

void

 

FlushDormancy

(
    AActor* Actor
)

Public function

void

 

FlushDormancyForObject

(
    UObject* Object
)

Wrapper for validating an objects dormancy state, and to prepare the object for replication again

Public function Virtual

void

 

FlushNet

(
    bool bIgnoreSimulation
)

Flushes any pending data, bundling it into a packet and sending it via LowLevelSend() also handles network simulation settings (simulated lag, packet loss, etc) unless bIgnoreSimulation is true

Public function

void

 

FlushPacketOrderCache

(
    bool bFlushWholeCache
)

Flush the cache of sequenced packets waiting for a missing packet.

Public function

void

 

ForcePropertyCompare

(
    AActor* Actor
)

Forces properties on this actor to do a compare for one frame (rather than share shadow state)

Public function

TMap< FString, TArray< float > > &

 

GetActorsStarvedByClassTimeMap()

Returns the actor starvation map

Public function Virtual

int32

 

GetAddrPort()

Public function Const

FName

 

GetClientWorldPackageName()

Public function

UControlChannel *

 

GetControlChannel()

Public function

TSet< FNetworkGUID > &

 

GetDestroyedStartupOrDormantActorGUIDs()

Public function

UNetDriver *

 

GetDriver()

Public function Const

const UNetDriver *

 

GetDriver()

Public function

int64

 

GetFreeSendBufferBits()

Returns number of bits left in current packet that can be used without causing a flush.

Public function Const

int32

 

GetMaxSingleBunchSizeBits()

The maximum number of bits allowed within a single bunch.

Public function Const

FHistogram

 

GetNetHistogram()

Public function

TArray< FOutBunch * > &

 

GetOutgoingBunches()

Returns the OutgoingBunches array, only to be used by UChannel::SendBunch

Public function Const

uint32

 

GetOutTotalNotifiedPackets()

Get the current number of sent packets for which we have received a delivery notification

Public function Const

const FNetConnectionPacketAnalytics &

 

GetPacketAnalytics()

Returns the current packet stability analytics.

Public function Const

FName

 

GetPlayerOnlinePlatformName()

Returns the online platform name for the player on this connection.

Public function Const

const FNetQueuedActorDelinquencyAnalytics &

 

GetQueuedActorDelinquencyAnalytics()

Returns the current delinquency analytics.

Public function Virtual

TSharedPtr< const FInternetAddr >

 

GetRemoteAddr()

Return the platform specific FInternetAddr type, containing this connections address.

Public function

UReplicationConnectionDriver *

 

GetReplicationConnectionDriver()

Public function Const

const FNetConnectionSaturationAnalytics &

 

GetSaturationAnalytics()

Returns the current saturation analytics.

Public function

float

 

GetTimeoutValue()

Return current timeout value that should be used

Public function Virtual

UChildConnection *

 

GetUChildConnection()

Get the representation of a secondary splitscreen connection that reroutes calls to the parent connection

Public function

UVoiceChannel *

 

GetVoiceChannel()

Public function Virtual Const

UWorld *

 

GetWorld()

Get the world the connection belongs to

Public function Virtual

void

 

HandleClientPlayer

(
    APlayerController* PC,
    UNetConnection* NetConnection
)

Handle the player controller client

Public function

bool

 

HasReceivedClientPacket()

Whether or not a client packet has been received - used serverside, to delay any packet sends

Public function Virtual

void

 

InitBase

(
    UNetDriver* InDriver,
    FSocket* InSocket,
    const FURL& InURL,
    EConnectionState InState,
    int32 InMaxPacket,
    int32 InPacketOverhead
)

Initialize common settings for this connection instance

Public function Virtual

void

 

InitConnection

(
    UNetDriver* InDriver,
    EConnectionState InState,
    const FURL& InURL,
    int32 InConnectionSpeed,
    int32 InMaxPacket
)

Initializes an "addressless" connection with the passed in settings

Public function Virtual

void

 

InitHandler()

Initializes the PacketHandler

Public function Virtual

void

 

InitLocalConnection

(
    UNetDriver* InDriver,
    FSocket* InSocket,
    const FURL& InURL,
    EConnectionState InState,
    int32 InMaxPacket,
    int32 InPacketOverhead
)

Initialize this connection instance to a remote source

Public function Virtual

void

 

InitRemoteConnection

(
    UNetDriver* InDriver,
    FSocket* InSocket,
    const FURL& InURL,
    const FInternetAddr& InRemoteAddr,
    EConnectionState InState,
    int32 InMaxPacket,
    int32 InPacketOverhead
)

Initialize this connection instance from a remote source

Public function Virtual

void

 

InitSendBuffer()

Resets the FBitWriter to its default state

Public function Virtual

void

 

InitSequence

(
    int32 IncomingSequence,
    int32 OutgoingSequence
)

Initializes the sequence numbers for the connection, usually from shared randomized data

Public function

bool

 

IsClientMsgTypeValid

(
    const uint8 ClientMsgType
)

This function validates that ClientMsgType is the next expected msg type.

Public function Const

bool

 

IsEncryptionEnabled()

Returns true if encryption is enabled for this connection.

Public function Virtual

int32

 

IsNetReady

(
    bool Saturate
)

Return whether this channel is ready for sending.

Public function Virtual

FString

 

LowLevelDescribe()

Public function Virtual

FString

 

LowLevelGetRemoteAddress

(
    bool bAppendPort
)

Public function Virtual

void

 

LowLevelSend

(
    void* Data,
    int32 CountBits,
    FOutPacketTraits& Traits
)

Sends a byte stream to the remote endpoint using the underlying socket

Public function Virtual

void

 

NotifyActorNetGUID

(
    UActorChannel* Channel
)

Called when an actor channel is open and knows its NetGUID.

Public function Virtual

void

 

NotifyAnalyticsProvider()

Notification that the NetDriver analytics provider has been updated NOTE: Can also mean disabled, e.g. during hotfix

Public function

void

 

PopLastStart()

Pops the LastStart bits off of the send buffer, used for merging bunches

Public function

void

 

PostTickDispatch()

Public function

void

 

ReadInput

(
    float DeltaSeconds
)

Read input

Public function

void

 

ReceivedNak

(
    int32 NakPacketId
)

Packet was negatively acknowledged.

Public function

void

 

ReceivedPacket

(
    FBitReader& Reader
)

Handle a packet we just received.

Public function Virtual

void

 

ReceivedRawPacket

(
    void* Data,
    int32 Count
)

Allows the connection to process the raw data that was received

Public function Virtual

FString

 

RemoteAddressToString()

Gets a unique ID for the connection, this ID depends on the underlying connection For IP connections this is an IP Address and port, for steam this is a SteamID

Public function

void

 

RemoveActorChannel

(
    AActor* Actor
)

Actor Channel Accessors

Public function

void

 

RemoveDestructionInfo

(
    FActorDestructionInfo* DestructionInfo
)

Public function

void

 

ResetActorsStarvedByClassTimeMap()

Clears the actor starvation map

Public function

void

 

ResetDestructionInfos()

Public function

void

 

ResetGameWorldState()

Clear all Game specific state. Called during seamless travel

Public function

void

 

ResetPacketAnalytics()

Resets the current packet stability analytics.

Public function

void

 

ResetPacketBitCounts()

Sets all of the bit-tracking variables to zero.

Public function

void

 

ResetQueuedActorDelinquencyAnalytics()

Resets the current delinquency analytics.

Public function

void

 

ResetSaturationAnalytics()

Resets the current saturation analytics.

Public function

void

 

SendChallengeControlMessage

(
    const FEncryptionKeyResponse& Response
)

Sends the NMT_Challenge message based on encryption response

Public function

void

 

SendChallengeControlMessage()

Sends the NMT_Challenge message

Public function

void

 

SendClientEncryptionAck()

Sends an NMT_EncryptionAck message

Public function

int32

 

SendRawBunch

(
    FOutBunch& Bunch,
    bool InAllowMerge
)

Send a raw bunch.

Public function

void

 

SetClientLoginState

(
    const EClientLoginState::Type NewState
)

Wrapper for setting the current client login state, so we can trap for debugging, and verbosity purposes.

Public function

void

 

SetClientWorldPackageName

(
    FName NewClientWorldPackageName
)

Public function

void

 

SetEncryptionData

(
    const FEncryptionData& EncryptionData
)

Sets the data for the underlying encryption packet handler component, but doesn't modify encryption enabled state.

Public function

void

 

SetExpectedClientLoginMsgType

(
    const uint8 NewType
)

Wrapper for setting the current expected client login msg type.

Public function

void

 

SetIgnoreActorBunches

(
    bool bInIgnoreActorBunches,
    TSet< FNetworkGUID >&& InIgnoredBunchGuids
)

Sets whether or not we should ignore bunches for a specific set of NetGUIDs.

Public function

void

 

SetIgnoreAlreadyOpenedChannels

(
    bool bInIgnoreAlreadyOpenedChannels
)

Sets whether or not we should ignore bunches that would attempt to open channels that are already open.

Public function

void

 

SetPacketOSReceiveTime

(
    const FPacketTimestamp& InOSReceiveTime,
    bool bInIsOSReceiveTimeLocal
)

Sets the OS/NIC level timestamp, for the last packet that was received

Protected function

void

 

SetPendingCloseDueToSocketSendFailure()

Public function

void

 

SetPlayerOnlinePlatformName

(
    const FName InPlayerOnlinePlatformName
)

Sets the PlayerOnlinePlatformName member.

Public function

void

 

SetReplicationConnectionDriver

(
    UReplicationConnectionDriver* NewReplicationConnectionDriver
)

Public function

bool

 

ShouldReplicateVoicePacketFrom

(
    const FUniqueNetId& Sender
)

Called to determine if a voice packet should be replicated to this connection or any of its child connections

Public function

void

 

SlowAssertValid()

Make sure this connection is in a reasonable state.

Public function

void

 

StartTickingChannel

(
    UChannel* Channel
)

Adds the channel to the ticking channels list.

Public function

void

 

StopTickingChannel

(
    UChannel* Channel
)

Removes a channel from the ticking list directly

Public function

void

 

TearDownReplicationConnectionDriver()

Public function Virtual

void

 

Tick()

Poll the connection. If it is timed out, close it.

Public function

bool

 

TrackLogsPerSecond()

This function tracks the number of log calls per second for this client, and disconnects the client if it detects too many calls are made per second

Public function

void

 

TrackReplicationForAnalytics

(
    const bool bWasSaturated
)

Called to notify the connection that we attempted to replicate its actors this frame.

Public function

void

 

UpdateLevelVisibility

(
    const FUpdateLevelVisibilityLevelInfo& LevelVisibility
)

Called by PlayerController to tell connection about client level visiblity change

Public function

void

 

UpdatePacketSimulationSettings()

Copies the settings from the net driver to our local copy

Public function Virtual

void

 

ValidateSendBuffer()

Validates the FBitWriter to make sure it's not in an error state

Public function

int32

 

WriteBitsToSendBuffer

(
    const uint8* Bits,
    const int32 SizeInBits,
    const uint8* ExtraBits,
    const int32 ExtraSizeInBits,
    EWriteBitsDataType DataType
)

Appends the passed in data to the SendBuffer to be sent when FlushNet is called

Overridden from UObject

Name Description

Public function Virtual

void

 

FinishDestroy()

Called to finish destroying the object.

Public function Virtual

void

 

Serialize

(
    FArchive& Ar
)

Handles reading, writing, and reference collecting using FArchive.

Overridden from FExec

Name Description

Public function Virtual

bool

 

Exec

(
    UWorld* InWorld,
    const TCHAR* Cmd,
    FOutputDevice& Ar
)

Exec handler

Enums

Name

Description

Public enum

EWriteBitsDataType

What type of data is being written

Constants

Name

Description

DEFAULT_MAX_CHANNEL_SIZE

Channel table.

GNetConnectionBeingCleanedUp

: set to net connection currently inside CleanUp(), for HasClientLoadedCurrentWorld() to be able to find it during PlayerController destruction, since we clear its Player before destroying it.

Deprecated Functions

Name Description

Public function

void

 

EnableEncryptionWithKey

(
    TArrayView< const uint8 > Key
)

Use SetEncryptionData instead.

Public function

void

 

EnableEncryptionWithKeyServer

(
    TArrayView< const uint8 > Key
)

Use SetEncryptionData instead.

Public function

void

 

SetEncryptionKey

(
    TArrayView< const uint8 > Key
)

Use SetEncryptionData instead.

Public function

void

 

UpdateLevelVisibility

(
    const FName& PackageName,
    bool bIsVisible
)

This method will be removed. Use UpdateLevelVisibility that takes an FUpdateLevelVisibilityLevelInfo

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback