UMinimalClient

Base class for implementing a barebones/stripped-down game client, capable of connecting to a regular game server, but stripped/locked-down so that the absolute minimum of client/server netcode functionality is executed, for connecting the client.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

NetcodeUnitTest

Header

/Engine/Plugins/NetcodeUnitTest/NetcodeUnitTest/Source/NetcodeUnitTest/Classes/MinimalClient.h

Include

#include "MinimalClient.h"

Syntax

[UCLASS](Programming/UnrealArchitecture/Reference/Classes#classdeclaration)()
class UMinimalClient :
    public UObject,
    public FNetworkNotify,
    public FProtMinClientParms,
    public FProtMinClientHooks,
    public FUnitLogRedirect

Remarks

Base class for implementing a barebones/stripped-down game client, capable of connecting to a regular game server, but stripped/locked-down so that the absolute minimum of client/server netcode functionality is executed, for connecting the client.

Variables

Name Description

Protected variable

bool

 

bConnected

Runtime variables Whether or not the minimal client is connected

Protected variable

bool

 

bSentBunch

Whether or not a bunch was successfully sent

Protected variable

TArray< int32 >

 

PendingNetActorChans

If notifying of net actor creation, this keeps track of new actor channel indexes pending notification

Protected variable

UNetConnection ...

 

UnitConn

Stores a reference to the server connection

Protected variable

UNetDriver *...

 

UnitNetDriver

Stores a reference to the created unit test net driver, for execution and later cleanup

Protected variable

UWorld *

 

UnitWorld

Stores a reference to the created empty world, for execution and later cleanup

Constructors

Name Description

Public function

UMinimalClient

(
    const FObjectInitializer& ObjectIn...
)

UMinimalClient

Functions

Name Description

Public function

void

 

Cleanup()

Disconnects and cleans up the minimal client.

Public function

bool

 

Connect

(
    FMinClientParms Parms,
    FMinClientHooks Hooks
)

Connects the minimal client to a server, with Parms specifying the server details and minimal client configuration, and passing back the low level netcode events specified by Hooks.

Protected function

bool

 

ConnectMinimalClient()

Creates the minimal client state, and connects to the server

Public function

FOutBunch &#...

 

CreateChannelBunchByName

(
    const FName& ChName,
    int32 ChIndex
)

Creates a bunch for the specified channel, with the ability to create the channel as well WARNING: Can return nullptr! (e.g. if the control channel is saturated)

Protected function

void

 

CreateNetDriver()

Creates a net driver for the minimal client

Public function

void

 

DiscardChannelBunch

(
    FOutBunch* Bunch
)

Discards a created bunch, without sending it - don't use this for sent packets

Protected function

void

 

DisconnectMinimalClient()

Disconnects the minimal client - including destructing the net driver and such (tears down the whole connection) NOTE: Based upon the HandleDisconnect function, except removing parts that are undesired (e.g. which trigger level switch)

Public function

UNetConnecti...

 

GetConn()

Retrieve the value of UnitConn

Public function

EMinClientFl...

 

GetMinClientFlags()

Retrieve the value of MinClientFlags

Public function

UWorld *

 

GetUnitWorld()

Retrieve the value of UnitWorld

Protected function

void

 

InternalNotifyNetworkFailure

(
    UWorld* InWorld,
    UNetDriver* InNetDriver,
    ENetworkFailure::Type FailureType,
    const FString& ErrorString
)

Public function

bool

 

IsConnected()

Whether or not the minimal client is connected to the server

Public function Const

bool

 

IsTickable()

Whether or not the minimal client requires ticking.

Protected function

void

 

NotifyReceivedRawPacket

(
    void* Data,
    int32 Count,
    bool& bBlockReceive
)

See FOnReceivedRawPacket

Protected function

void

 

NotifyReceiveRPC

(
    AActor* Actor,
    UFunction* Function,
    void* Parameters,
    bool& bBlockRPC
)

See FOnProcessNetEvent

Protected function

void

 

NotifySendRPC

(
    AActor* Actor,
    UFunction* Function,
    void* Parameters,
    FOutParmRec* OutParms,
    FFrame* Stack,
    UObject* SubObject,
    bool& bBlockSendRPC
)

See FOnSendRPC

Protected function

void

 

NotifySocketSend

(
    void* Data,
    int32 Count,
    bool& bBlockSend
)

See FOnLowLevelSend

Public function

bool

 

PostSendRPC

(
    FString RPCName,
    UObject* Target
)

Internal function, for handling the aftermath of a checked RPC call

Public function

void

 

PreSendRPC()

Internal function, for preparing for a checked RPC call

Public function

void

 

ResetConnTimeout

(
    float Duration
)

Resets the net connection timeout

Public function

bool

 

SendControlBunch

(
    FOutBunch* ControlChanBunch
)

Sends a bunch over the control channel

Protected function

void

 

SendInitialJoin()

Sends the packet for triggering the initial join (usually is delayed, by the PacketHandler)

Public function

bool

 

SendRawBunch

(
    FOutBunch& Bunch,
    bool bAllowPartial
)

Sends a raw packet bunch, directly to the NetConnection, with the option of automatically splitting into partial bunches.

Public function

bool

 

SendRPCChecked

(
    UObject* Target,
    FFuncReflection& FuncRefl
)

As above, except optimized for use with reflection

Public function

bool

 

SendRPCChecked

(
    UObject* Target,
    const TCHAR* FunctionName,
    void* Parms,
    int16 ParmsSize,
    int16 ParmsSizeCorrection
)

Sends the specified RPC for the specified actor, and verifies that the RPC was sent (triggering RPCFailureDel if not)

Public function

void

 

UnitTick

(
    float DeltaTime
)

Ticks the minimal client, through the owner unit tests UnitTick function

Protected function Virtual

void

 

WriteControlLogin

(
    FOutBunch* ControlChanBunch
)

Writes the NMT_Login message, as a part of SendInitialJoin (separated to make it overridable)

Overridden from FNetworkNotify

Name Description

Protected function Virtual

void

 

NotifyAcceptedConnection

(
    UNetConnection* Connection
)

Notification that a new connection has been created/established as a result of a remote request, previously approved by NotifyAcceptingConnection

Protected function Virtual

bool

 

NotifyAcceptingChannel

(
    UChannel* Channel
)

Notification that a new channel is being created/opened as a result of a remote request (Actor creation, etc)

Protected function Virtual

EAcceptConne...

 

NotifyAcceptingConnection()

FNetworkNotify.

Protected function Virtual

void

 

NotifyControlMessage

(
    UNetConnection* Connection,
    uint8 MessageType,
    FInBunch& Bunch
)

Handler for messages sent through a remote connection's control channel not required to handle the message, but if it reads any data from Bunch, it MUST read the ENTIRE data stream for that message (i.e. use FNetControlMessage::Receive())

Deprecated Functions

Name Description

Public function

FOutBunch &#...

 

CreateChannelBunch

(
    EChannelType ChType,
    int32 ChIndex
)

Use CreateChannelBunchByName

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