UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PacketHandler Class Reference

#include <PacketHandler.h>

+ Inheritance diagram for PacketHandler:

Public Member Functions

 PacketHandler (ReadOnlyTargetRules Target)
 
PACKETHANDLER_API PacketHandler (FDDoSDetection *InDDoS=nullptr)
 
PACKETHANDLER_API void Initialize (UE::Handler::Mode Mode, uint32 InMaxPacketBits, bool bConnectionlessOnly=false, TSharedPtr< class IAnalyticsProvider > InProvider=nullptr, FDDoSDetection *InDDoS=nullptr, FName InDriverProfile=NAME_None)
 
PACKETHANDLER_API void InitializeDelegates (FPacketHandlerLowLevelSendTraits InLowLevelSendDel, FPacketHandlerNotifyAddHandler InAddHandlerDel=FPacketHandlerNotifyAddHandler())
 
PACKETHANDLER_API void InitFaultRecovery (UE::Net::FNetConnectionFaultRecoveryBase *InFaultRecovery)
 
PACKETHANDLER_API void NotifyAnalyticsProvider (TSharedPtr< IAnalyticsProvider > InProvider, TSharedPtr< FNetAnalyticsAggregator > InAggregator)
 
PACKETHANDLER_API void InitializeComponents ()
 
PACKETHANDLER_API void BeginHandshaking (FPacketHandlerHandshakeComplete InHandshakeDel=FPacketHandlerHandshakeComplete())
 
PACKETHANDLER_API void Tick (float DeltaTime)
 
PACKETHANDLER_API void AddHandler (TSharedPtr< HandlerComponent > &NewHandler, bool bDeferInitialize=false)
 
PACKETHANDLER_API TSharedPtr< HandlerComponentAddHandler (const FString &ComponentStr, bool bDeferInitialize=false)
 
PACKETHANDLER_API void IncomingHigh (FBitReader &Reader)
 
PACKETHANDLER_API void OutgoingHigh (FBitWriter &Writer)
 
const ProcessedPacket Incoming (uint8 *Packet, int32 CountBytes)
 
EIncomingResult Incoming (FReceivedPacketView &PacketView)
 
const ProcessedPacket Outgoing (uint8 *Packet, int32 CountBits, FOutPacketTraits &Traits)
 
const ProcessedPacket IncomingConnectionless (const TSharedPtr< const FInternetAddr > &Address, uint8 *Packet, int32 CountBytes)
 
EIncomingResult IncomingConnectionless (FReceivedPacketView &PacketView)
 
const ProcessedPacket OutgoingConnectionless (const TSharedPtr< const FInternetAddr > &Address, uint8 *Packet, int32 CountBits, FOutPacketTraits &Traits)
 
PACKETHANDLER_API TSharedPtr< FEncryptionComponentGetEncryptionComponent ()
 
PACKETHANDLER_API TSharedPtr< HandlerComponentGetComponentByName (FName ComponentName) const
 
PACKETHANDLER_API void CountBytes (FArchive &Ar) const
 
PACKETHANDLER_API void SendHandlerPacket (HandlerComponent *InComponent, FBitWriter &Writer, FOutPacketTraits &Traits)
 
PACKETHANDLER_API void HandlerComponentInitialized (HandlerComponent *InComponent)
 
void QueuePacketForRawSending (BufferedPacket *PacketToQueue)
 
void QueueHandlerPacketForSending (BufferedPacket *PacketToQueue)
 
PACKETHANDLER_API BufferedPacketGetQueuedPacket ()
 
PACKETHANDLER_API BufferedPacketGetQueuedRawPacket ()
 
PACKETHANDLER_API BufferedPacketGetQueuedConnectionlessPacket ()
 
PACKETHANDLER_API int32 GetTotalReservedPacketBits ()
 
void SetRawSend (bool bInEnabled)
 
bool GetRawSend ()
 
bool IsFullyInitialized ()
 
FDDoSDetectionGetDDoS () const
 
TSharedPtr< IAnalyticsProviderGetProvider () const
 
TSharedPtr< FNetAnalyticsAggregatorGetAggregator () const
 

Static Public Member Functions

static PACKETHANDLER_API bool DoesAnyProfileHaveComponent (const FString &InComponentName)
 
static PACKETHANDLER_API bool DoesProfileHaveComponent (const FName InNetDriverName, const FString &InComponentName)
 
static PACKETHANDLER_API FPacketHandlerAddComponentByNameDelegateGetAddComponentByNameDelegate ()
 
static PACKETHANDLER_API FPacketHandlerAddComponentDelegateGetAddComponentDelegate ()
 

Public Attributes

UE::Handler::Mode Mode
 

Protected Member Functions

const ProcessedPacket Incoming_Internal (uint8 *Packet, int32 CountBytes, bool bConnectionless, const TSharedPtr< const FInternetAddr > &Address)
 
PACKETHANDLER_API EIncomingResult Incoming_Internal (FReceivedPacketView &PacketView)
 
PACKETHANDLER_API const ProcessedPacket Outgoing_Internal (uint8 *Packet, int32 CountBits, FOutPacketTraits &Traits, bool bConnectionless, const TSharedPtr< const FInternetAddr > &Address)
 

Detailed Description

This class maintains an array of all PacketHandler Components and forwards incoming and outgoing packets the each component

Constructor & Destructor Documentation

◆ PacketHandler() [1/2]

PacketHandler.PacketHandler ( ReadOnlyTargetRules  Target)
inline

◆ PacketHandler() [2/2]

PacketHandler::PacketHandler ( FDDoSDetection InDDoS = nullptr)

Base constructor

Parameters
InDDoSReference to the owning net drivers DDoS detection handler

PacketHandler

Member Function Documentation

◆ AddHandler() [1/2]

TSharedPtr< HandlerComponent > PacketHandler::AddHandler ( const FString &  ComponentStr,
bool  bDeferInitialize = false 
)

As above, but initializes from a string specifying the component module, and (optionally) additional options

Parameters
ComponentStrThe handler component to load
bDeferInitializeWhether or not to defer triggering Initialize (for batch-adds - code calling this, triggers it instead)

◆ AddHandler() [2/2]

void PacketHandler::AddHandler ( TSharedPtr< HandlerComponent > &  NewHandler,
bool  bDeferInitialize = false 
)

Adds a HandlerComponent to the pipeline, prior to initialization (none can be added after initialization)

Parameters
NewHandlerThe HandlerComponent to add
bDeferInitializeWhether or not to defer triggering Initialize (for batch-adds - code calling this, triggers it instead)

◆ BeginHandshaking()

void PacketHandler::BeginHandshaking ( FPacketHandlerHandshakeComplete  InHandshakeDel = FPacketHandlerHandshakeComplete())

Triggered by the higher level netcode, to begin any required HandlerComponent handshakes

◆ CountBytes()

void PacketHandler::CountBytes ( FArchive Ar) const

◆ DoesAnyProfileHaveComponent()

bool PacketHandler::DoesAnyProfileHaveComponent ( const FString &  InComponentName)
static

Searches the PacketHandler profile configurations to find if a component is listed.

Parameters
InComponentNameThe PacketHandler Component to search for
Returns
if there is a profile that has the component included.

◆ DoesProfileHaveComponent()

bool PacketHandler::DoesProfileHaveComponent ( const FName  InNetDriverName,
const FString &  InComponentName 
)
static

Searches the PacketHandler profile configuration for the given netdriver to find if a component is listed.

Parameters
InNetDriverNameThe name of the netdriver to search configuration for
InComponentNameThe component to search for
Returns
if the component is listed in the profile configuration.

◆ GetAddComponentByNameDelegate()

FPacketHandlerAddComponentByNameDelegate & PacketHandler::GetAddComponentByNameDelegate ( )
static

◆ GetAddComponentDelegate()

FPacketHandlerAddComponentDelegate & PacketHandler::GetAddComponentDelegate ( )
static

◆ GetAggregator()

TSharedPtr< FNetAnalyticsAggregator > PacketHandler.GetAggregator ( ) const
inline

Returns the analytics aggregator

◆ GetComponentByName()

TSharedPtr< HandlerComponent > PacketHandler::GetComponentByName ( FName  ComponentName) const

Returns a pointer to the first component in the HandlerComponents array with the specified name.

◆ GetDDoS()

FDDoSDetection * PacketHandler.GetDDoS ( ) const
inline

Returns a pointer to the DDoS detection handler

◆ GetEncryptionComponent()

TSharedPtr< FEncryptionComponent > PacketHandler::GetEncryptionComponent ( )

Returns a pointer to the component set as the encryption handler, if any.

◆ GetProvider()

TSharedPtr< IAnalyticsProvider > PacketHandler.GetProvider ( ) const
inline

Returns the analytics provider

◆ GetQueuedConnectionlessPacket()

BufferedPacket * PacketHandler::GetQueuedConnectionlessPacket ( )

Gets a packet from the buffered connectionless packet queue for sending

Returns
The packet to be sent, or nullptr if none are to be sent

◆ GetQueuedPacket()

BufferedPacket * PacketHandler::GetQueuedPacket ( )

Gets a packet from the buffered packet queue for sending

Returns
The packet to be sent, or nullptr if none are to be sent

◆ GetQueuedRawPacket()

BufferedPacket * PacketHandler::GetQueuedRawPacket ( )

Gets a packet from the buffered packet queue for sending (as a raw packet)

Returns
The packet to be sent, or nullptr if none are to be sent

◆ GetRawSend()

bool PacketHandler.GetRawSend ( )
inline

Whether or not raw packet sends are enabled

◆ GetTotalReservedPacketBits()

int32 PacketHandler::GetTotalReservedPacketBits ( )

Gets the combined reserved packet/protocol bits from all handlers, for reserving space in the parent connections packets

Returns
The combined reserved packet/protocol bits

◆ HandlerComponentInitialized()

void PacketHandler::HandlerComponentInitialized ( HandlerComponent InComponent)

Triggered when a child HandlerComponent has been initialized

◆ Incoming() [1/2]

EIncomingResult PacketHandler.Incoming ( FReceivedPacketView PacketView)
inline

Processes incoming packets at the PacketHandler level, before any UNetConnection processing takes place on the packet.

Use this for more complex changes to packets, such as compression/encryption, but be aware that compatibility problems with other HandlerComponent's are more likely.

Parameters
PacketViewView of the packet being processed - PacketView.Data should be used to return the result
Returns
Returns Success/Failure

◆ Incoming() [2/2]

const ProcessedPacket PacketHandler.Incoming ( uint8 Packet,
int32  CountBytes 
)
inline

◆ Incoming_Internal() [1/2]

EIncomingResult PacketHandler::Incoming_Internal ( FReceivedPacketView PacketView)
protected

Internal handling for Incoming/IncomingConnectionless

Parameters
PacketViewView of the packet being processed - PacketView.Data should be used to return the result
Returns
Returns Success/Failure

◆ Incoming_Internal() [2/2]

const ProcessedPacket PacketHandler.Incoming_Internal ( uint8 Packet,
int32  CountBytes,
bool  bConnectionless,
const TSharedPtr< const FInternetAddr > &  Address 
)
inlineprotected

◆ IncomingConnectionless() [1/2]

const ProcessedPacket PacketHandler.IncomingConnectionless ( const TSharedPtr< const FInternetAddr > &  Address,
uint8 Packet,
int32  CountBytes 
)
inline

◆ IncomingConnectionless() [2/2]

EIncomingResult PacketHandler.IncomingConnectionless ( FReceivedPacketView PacketView)
inline

Processes incoming packets without a UNetConnection, in the same manner as 'Incoming' above IMPORTANT: Net drivers triggering this, should call 'UNetDriver::FlushHandler' shortly afterwards, to minimize packet buffering NOTE: Connectionless packets are unreliable.

Parameters
PacketViewView of the packet being processed - PacketView.Data should be used to return the result
Returns
Returns Success/Failure

◆ IncomingHigh()

void PacketHandler::IncomingHigh ( FBitReader Reader)

Processes incoming packets at the UNetConnection level, after uncapping the packet into an FBitReader.

Use this for simple data additions to packets, and for maximum compatibility with other HandlerComponent's.

Parameters
ReaderThe FBitReader for the incoming packet

◆ InitFaultRecovery()

void PacketHandler::InitFaultRecovery ( UE::Net::FNetConnectionFaultRecoveryBase *  InFaultRecovery)

Initializes a reference to the NetConnection fault recovery interface (does not require Engine dependency)

Parameters
InFaultRecoveryA reference to the fault recovery interface

◆ Initialize()

void PacketHandler::Initialize ( UE::Handler::Mode  Mode,
uint32  InMaxPacketBits,
bool  bConnectionlessOnly = false,
TSharedPtr< class IAnalyticsProvider InProvider = nullptr,
FDDoSDetection InDDoS = nullptr,
FName  InDriverProfile = NAME_None 
)

Handles initialization of manager

Parameters
ModeThe mode the manager should be initialized in
InMaxPacketBitsThe maximum supported packet size
bConnectionlessOnlyWhether or not this is a connectionless-only manager (ignores .ini components)
InProviderThe analytics provider
InDDoSReference to the owning net drivers DDoS detection handler
InDriverProfileThe PacketHandler configuration profile to use

◆ InitializeComponents()

void PacketHandler::InitializeComponents ( )

Triggers initialization of HandlerComponents.

◆ InitializeDelegates()

void PacketHandler::InitializeDelegates ( FPacketHandlerLowLevelSendTraits  InLowLevelSendDel,
FPacketHandlerNotifyAddHandler  InAddHandlerDel = FPacketHandlerNotifyAddHandler() 
)

Used for external initialization of delegates

Parameters
InLowLevelSendDelThe delegate the PacketHandler should use for triggering packet sends
InAddHandlerDelCallback for notifying of new HandlerComponent's

◆ IsFullyInitialized()

bool PacketHandler.IsFullyInitialized ( )
inline

Whether or not the packet handler is fully initialized, post-handshake etc.

◆ NotifyAnalyticsProvider()

void PacketHandler::NotifyAnalyticsProvider ( TSharedPtr< IAnalyticsProvider InProvider,
TSharedPtr< FNetAnalyticsAggregator InAggregator 
)

Notification that the NetDriver analytics provider has been updated (NOT called on first initialization) NOTE: Can also mean disabled, e.g. during hotfix

Parameters
InProviderThe analytics provider
InAggregatorThe net analytics aggregator

◆ Outgoing()

const ProcessedPacket PacketHandler.Outgoing ( uint8 Packet,
int32  CountBits,
FOutPacketTraits Traits 
)
inline

Processes outgoing packets at the PacketHandler level, after all UNetConnection processing.

Use this for more complex changes to packets, such as compression/encryption, but be aware that compatibility problems with other HandlerComponent's are more likely.

Parameters
PacketThe packet data to be processed
CountBitsThe size of the packet data in bits
TraitsTraits for the packet, passed down from the NetConnection
Returns
Returns the final packet

◆ Outgoing_Internal()

const ProcessedPacket PacketHandler::Outgoing_Internal ( uint8 Packet,
int32  CountBits,
FOutPacketTraits Traits,
bool  bConnectionless,
const TSharedPtr< const FInternetAddr > &  Address 
)
protected

Internal handling for Outgoing/OutgoingConnectionless

Parameters
PacketThe packet data to be processed
CountBitsThe size of the packet data in bits
TraitsTraits for the packet, passed down from the NetConnection, if applicable
bConnectionlessWhether or not this should be sent as a connectionless packet
AddressThe address the packet is being sent to
Returns
Returns the final packet

◆ OutgoingConnectionless()

const ProcessedPacket PacketHandler.OutgoingConnectionless ( const TSharedPtr< const FInternetAddr > &  Address,
uint8 Packet,
int32  CountBits,
FOutPacketTraits Traits 
)
inline

Processes outgoing packets without a UNetConnection, in the same manner as 'Outgoing' above NOTE: Connectionless packets are unreliable.

Parameters
AddressThe address the packet is being sent to
PacketThe packet data to be processed
CountBitsThe size of the packet data in bits
TraitsTraits for the packet, if applicable
Returns
Returns the final packet

◆ OutgoingHigh()

void PacketHandler::OutgoingHigh ( FBitWriter Writer)

Processes outgoing packets at the UNetConnection level, after game data is written, and just before the packet is capped.

Use this for simple data additions to packets, and for maximum compatibility with other HandlerComponent's.

Parameters
WriterThe FBitWriter for the outgoing packet

◆ QueueHandlerPacketForSending()

void PacketHandler.QueueHandlerPacketForSending ( BufferedPacket PacketToQueue)
inline

Queue's a packet to be sent through 'SendHandlerPacket'

Parameters
PacketToQueueThe packet to be queued

◆ QueuePacketForRawSending()

void PacketHandler.QueuePacketForRawSending ( BufferedPacket PacketToQueue)
inline

Queue's a packet to be sent when the handler is ticked (as a raw packet, since it's already been processed)

Parameters
PacketToQueueThe packet to be queued

◆ SendHandlerPacket()

void PacketHandler::SendHandlerPacket ( HandlerComponent InComponent,
FBitWriter Writer,
FOutPacketTraits Traits 
)

Send a packet originating from a HandlerComponent - will process through the HandlerComponents chain, starting after the triggering component. NOTE: Requires that InitializeDelegates is called, with a valid LowLevelSend delegate.

Parameters
ComponentThe HandlerComponent sending the packet
WriterThe packet being sent
TraitsThe traits applied to the packet, if applicable

◆ SetRawSend()

void PacketHandler.SetRawSend ( bool  bInEnabled)
inline

Sets whether or not outgoing packets should bypass this handler - used when raw packet sends are necessary (such as for the stateless handshake)

Parameters
bInEnabledWhether or not raw sends are enabled

◆ Tick()

void PacketHandler::Tick ( float  DeltaTime)

Member Data Documentation

◆ Mode

UE::Handler::Mode PacketHandler.Mode

Mode of the handler, Client or Server


The documentation for this class was generated from the following files: