UDemoNetDriver

Simulated network driver for recording and playing back game sessions.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Engine/DemoNetDriver.h

Include

#include "Engine/DemoNetDriver.h"

Syntax

class UDemoNetDriver : public UNetDriver

Remarks

Simulated network driver for recording and playing back game sessions.

Variables

Name Description

Public variable

double

 

AccumulatedRecordTime

Internal debug timing/tracking

Protected variable

bool

 

bIsWaitingForHeaderDownload

Protected variable

bool

 

bIsWaitingForStream

Public variable

double

 

LastRecordAvgFlush

Protected variable

int64

 

MaxArchiveReadPos

Public variable

double

 

MaxRecordTime

Public variable

TArray< FPlayba...

 

PlaybackPackets

PlaybackPackets are used to buffer packets up when we read a demo frame, which we can then process when the time is right

Protected variable

TArray< FQueued...

 

QueuedPacketsBeforeTravel

Public variable

int32

 

RecordCountSinceFlush

Constructors

Name Description

Public function

UDemoNetDriver

(
    const FObjectInitializer& ObjectIn...
)

Public function

UDemoNetDriver

(
    FVTableHelper& Helper
)

Destructors

Name Description

Public function

~UDemoNetDriver()

Functions

Name Description

Public function

void

 

AddEvent

(
    const FString& Group,
    const FString& Meta,
    const TArray< uint8 >& Data
)

Public function

void

 

AddNonQueuedActorForScrubbing

(
    AActor const* Actor
)

If a channel is associated with Actor, adds the channel's GUID to the list of GUIDs excluded from queuing bunches during scrubbing.

Public function

void

 

AddNonQueuedGUIDForScrubbing

(
    FNetworkGUID InGUID
)

Adds the channel's GUID to the list of GUIDs excluded from queuing bunches during scrubbing.

Public function

void

 

AddOrUpdateEvent

(
    const FString& EventName,
    const FString& Group,
    const FString& Meta,
    const TArray< uint8 >& Data
)

Public function

void

 

AddReplayTask

(
    FQueuedReplayTask* NewTask
)

Public function

void

 

AddUserToReplay

(
    const FString& UserString
)

Adds a join-in-progress user to the set of users associated with the currently recording replay (if any)

Public function

void

 

ClearReplayTasks()

Public function Const

bool

 

ComparePropertyState

(
    const FDemoSavedPropertyState& Sta...
)

Compares the values of replicated properties stored in State with the current values of the object replicators.

Public function

bool

 

ConditionallyProcessPlaybackPackets()

Public function

bool

 

ConditionallyReadDemoFrameIntoPlaybackPackets

(
    FArchive& Ar
)

Public function

bool

 

ContinueListen

(
    FURL& ListenURL
)

Called when we are already recording but have traveled to a new map to start recording again

Protected function

bool

 

DemoReplicateActor

(
    AActor* Actor,
    UNetConnection* Connection,
    bool bMustReplicate
)

Public function

void

 

EnumerateEvents

(
    const FString& Group,
    const FEnumerateEventsCallback& De...
)

Public function

void

 

EnumerateEventsForActiveReplay

(
    const FString& Group,
    const int32 UserIndex,
    const FEnumerateEventsCallback& De...
)

In most cases, this is desirable over EnumerateEvents because it will explicitly use ActiveReplayName instead of letting the streamer decide.

Public function

void

 

EnumerateEventsForActiveReplay

(
    const FString& Group,
    const FEnumerateEventsCallback& De...
)

In most cases, this is desirable over EnumerateEvents because it will explicitly use ActiveReplayName instead of letting the streamer decide.

Public function

void

 

FinalizeFastForward

(
    const double StartTime
)

Public function Const

const FStrin...

 

GetActiveReplayName()

Gets the actively recording or playback replay (stream) name.

Public function Const

bool

 

GetChannelsArePaused()

Public function Const

double

 

GetCurrentLevelIndex()

Public function Const

float

 

GetDemoCurrentTime()

Current record/playback position in seconds

Public function Const

uint32

 

GetDemoCurrentTimeInMS()

Public function Const

int32

 

GetDemoFrameNum()

Public function Const

FString

 

GetDemoPath()

Public function Const

const FStrin...

 

GetDemoSessionID()

Public function Const

float

 

GetDemoTotalTime()

Total time of demo in seconds

Public function Const

FString

 

GetDemoURL()

Public function

FReplayExter...

 

GetExternalDataArrayForObject

(
    UObject* Object
)

Public function Const

double

 

GetLastCheckpointTime()

Public function Const

float

 

GetLastReplayFrameFidelity()

Replay frame fidelity.

Public function

const TArray...

 

GetLevelNameAndTimeList()

Public function Const

FName

 

GetNextQueuedTaskName()

Public function Const

uint32

 

GetPlaybackDemoVersion()

Public function Const

TSharedPtr< ...

 

GetReplayStreamer()

Public function Const

APlayerContr...

 

GetSpectatorController()

Public function

void

 

GotoTimeInSeconds

(
    const float TimeInSeconds,
    const FOnGotoTimeDelegate& InOnGot...
)

Scrubs playback to the given time.

Public function Const

bool

 

HasDeltaCheckpoints()

Returns whether or not this replay was recorded / is playing with delta checkpoints.

Public function Const

bool

 

HasGameSpecificFrameData()

Returns whether or not this replay was recorded / is playing with the game specific per frame data feature.

Public function Const

bool

 

HasLevelStreamingFixes()

Returns whether or not this replay was recorded / is playing with Level Streaming fixes.

Public function

bool

 

InitConnectInternal

(
    FString& Error
)

Public function Const

bool

 

IsAnyTaskPending()

Public function Const

bool

 

IsFastForwarding()

Public function Const

bool

 

IsFinalizingFastForward()

Public function Const

bool

 

IsLoadingCheckpoint()

Public function Const

bool

 

IsNamedTaskInQueue

(
    const FName& Name
)

Public function Const

bool

 

IsPlaying()

Public function Const

bool

 

IsPlayingClientReplay()

Public function Const

bool

 

IsRecording()

Public function Const

bool

 

IsRecordingMapChanges()

Public function Const

bool

 

IsRecordingPaused()

Public function Const

bool

 

IsSavingCheckpoint()

Returns true if we're in the process of saving a checkpoint.

Public function

void

 

JumpToEndOfLiveReplay()

Protected function

void

 

NotifyDemoPlaybackFailure

(
    EDemoPlayFailure::Type FailureType
)

Public function

void

 

NotifyGotoTimeFinished

(
    bool bWasSuccessful
)

Called when a "go to time" operation is completed.

Public function

void

 

OnSeamlessTravelStartDuringRecording

(
    const FString& LevelName
)

Called when seamless travel begins when recording a replay.

Public function

void

 

PauseChannels

(
    const bool bPause
)

Public function

void

 

PauseRecording

(
    const bool bInPauseRecording
)

Public function

void

 

ProcessAllPlaybackPackets()

Public function

bool

 

ProcessPacket

(
    const uint8* Data,
    int32 Count
)

Public function

bool

 

ProcessPacket

(
    const FPlaybackPacket& PlaybackPac...
)

Public function

bool

 

ProcessReplayTasks()

Protected function

void

 

ProcessSeamlessTravel

(
    int32 LevelIndex
)

Public function Virtual

void

 

QueueNetStartupActorForRollbackViaDeletion

(
    AActor* Actor
)

Call this function during playback to track net startup actors that need a hard reset when scrubbing, which is done by destroying and then re-spawning

Public function

bool

 

ReadDemoFrameIntoPlaybackPackets

(
    FArchive& Ar,
    TArray< FPlaybackPacket >& Packets,
    const bool bForLevelFastForward,
    float* OutTime
)

Public function

bool

 

ReadDemoFrameIntoPlaybackPackets

(
    FArchive& Ar
)

Public function

bool

 

RemoveSplitscreenViewer

(
    APlayerController* RemovePlaye...,
    bool bMarkOwnerForDeletion
)

Removes a splitscreen demo viewer and cleans up its connection.

Public function

void

 

ReplayStreamingReady

(
    const FStartStreamingResult& Resul...
)

Public function

void

 

RequestEventData

(
    const FString& EventID,
    const FRequestEventDataCallback& D...
)

Public function

void

 

RequestEventDataForActiveReplay

(
    const FString& EventID,
    const int32 UserIndex,
    const FRequestEventDataCallback& D...
)

In most cases, this is desirable over RequestEventData because it will explicitly use ActiveReplayName instead of letting the streamer decide.

Public function

void

 

RequestEventDataForActiveReplay

(
    const FString& EventID,
    const FRequestEventDataCallback& D...
)

In most cases, this is desirable over RequestEventData because it will explicitly use ActiveReplayName instead of letting the streamer decide.

Public function

void

 

RequestEventGroupDataForActiveReplay

(
    const FString& Group,
    const int32 UserIndex,
    const FRequestEventGroupDataCallbac...
)

Retrieve data for all events matching the requested group, and call the passed in delegate on completion.

Public function

void

 

RequestEventGroupDataForActiveReplay

(
    const FString& Group,
    const FRequestEventGroupDataCallbac...
)

Retrieve data for all events matching the requested group, and call the passed in delegate on completion.

Public function

void

 

ResetDemoState()

Public function

void

 

RespawnNecessaryNetStartupActors

(
    TArray< AActor* >& SpawnedAct...,
    ULevel* Level
)

Public function

void

 

RestoreConnectionPostScrub

(
    APlayerController* PC,
    UNetConnection* NetConnection
)

Restores the given player controller so that it properly points to the given NetConnection after scrubbing when viewing a replay.

Public function Const

FDemoSavedPr...

 

SavePropertyState()

Returns the replicated state of every object on a current actor channel.

Public function

void

 

SetActorPrioritizationEnabled

(
    const bool bInPrioritizeActors
)

Enable or disable prioritization of actors for recording.

Public function

void

 

SetCheckpointSaveMaxMSPerFrame

(
    const float InCheckpointSaveMaxMSPe...
)

Sets CheckpointSaveMaxMSPerFrame.

Public function

void

 

SetCurrentLevelIndex

(
    int32 Index
)

Public function

void

 

SetDemoCurrentTime

(
    float CurrentTime
)

Public function

void

 

SetDemoTotalTime

(
    float TotalTime
)

Public function

void

 

SetLastCheckpointTime

(
    double CheckpointTime
)

Public function

void

 

SetMaxDesiredRecordTimeMS

(
    const float InMaxDesiredRecordTimeM...
)

Sets the desired maximum recording time in milliseconds.

Public function

void

 

SetPlayingPlaylist

(
    TSharedPtr< struct FReplayPlaylistT...
)

Public function

void

 

SetSpectatorController

(
    APlayerController* PC
)

Sets the main spectator controller to be used and adds them to the spectator control array

Public function

void

 

SetViewerOverride

(
    APlayerController*const InView...
)

Sets the controller to use as the viewpoint for recording prioritization purposes.

Public function Const

bool

 

ShouldTickFlushAsyncEndOfFrame()

Returns true if TickFlush can be called in parallel with the Slate tick.

Public function

void

 

SkipTime

(
    const float InTimeToSkip
)

Public function

void

 

SkipTimeInternal

(
    const float SecondsToSkip,
    const bool InFastForward,
    const bool InIsForCheckpoint
)

Public function

void

 

SpawnDemoRecSpectator

(
    UNetConnection* Connection,
    const FURL& ListenURL
)

Public function

bool

 

SpawnSplitscreenViewer

(
    ULocalPlayer* NewPlayer,
    UWorld* InWorld
)

Creates a new splitscreen replay viewer.

Public function

void

 

StopDemo()

Public function

void

 

TickDemoPlayback

(
    float DeltaSeconds
)

Public function

void

 

TickDemoRecord

(
    float DeltaSeconds
)

Public function

void

 

TickFlushAsyncEndOfFrame

(
    float DeltaSeconds
)

Called by a task thread if the engine is doing async end of frame tasks in parallel with Slate.

Public function

void

 

WriteDemoFrameFromQueuedDemoPackets

(
    FArchive& Ar,
    TArray< FQueuedDemoPacket >& Queue...,
    float FrameTime,
    EWriteDemoFrameFlags Flags
)

Public function

void

 

WritePacket

(
    FArchive& Ar,
    uint8* Data,
    int32 Count
)

Overridden from UNetDriver

Name Description

Public function Virtual

void

 

ForceNetUpdate

(
    AActor* Actor
)

Game code API for updating server Actor Replication State

Public function Virtual Const

AActor *

 

GetActorForGUID

(
    FNetworkGUID InGUID
)

Returns the actor that corresponds to InGUID, if one can be found.

Public function Virtual Const

FNetworkGUID

 

GetGUIDForActor

(
    const AActor* InActor
)

Returns the existing FNetworkGUID of InActor, if it has one.

Public function Virtual

ISocketSubsy...

 

GetSocketSubsystem()

Get the socket subsytem appropriate for this net driver

Public function Virtual

bool

 

InitBase

(
    bool bInitAsClient,
    FNetworkNotify* InNotify,
    const FURL& URL,
    bool bReuseAddressAndPort,
    FString& Error
)

Common initialization between server and client connection setup

Public function Virtual

bool

 

InitConnect

(
    FNetworkNotify* InNotify,
    const FURL& ConnectURL,
    FString& Error
)

Initialize the net driver in client mode

Public function Virtual

void

 

InitDestroyedStartupActors()

Initialize the list of destroyed net startup actors from the current World

Public function Virtual

bool

 

InitListen

(
    FNetworkNotify* InNotify,
    FURL& ListenURL,
    bool bReuseAddressAndPort,
    FString& Error
)

Initialize the network driver in server mode (listener)

Protected function Virtual

UChannel ...

 

InternalCreateChannelByName

(
    const FName& ChName
)

Subclasses may override this to customize channel creation.

Public function Virtual Const

bool

 

IsAvailable()

Returns true if this net driver is valid for the current configuration.

Public function Virtual Const

bool

 

IsLevelInitializedForActor

(
    const AActor* InActor,
    const UNetConnection* InConnec...
)

Returns true if this actor is considered to be in a loaded level

Public function Virtual

bool

 

IsNetResourceValid()

Public function Virtual Const

bool

 

IsServer()

Public function Virtual

FString

 

LowLevelGetNetworkNumber()

Public function Virtual

void

 

LowLevelSend

(
    TSharedPtr< const FInternetAddr > A...,
    void* Data,
    int32 CountBits,
    FOutPacketTraits& Traits
)

Sends a 'connectionless' (not associated with a UNetConection) packet, to the specified address.

Public function Virtual

void

 

NotifyActorChannelCleanedUp

(
    UActorChannel* Channel,
    EChannelCloseReason CloseReason
)

Called when an actor channel is cleaned up foor an actor.

Public function Virtual

void

 

NotifyActorChannelOpen

(
    UActorChannel* Channel,
    AActor* Actor
)

Called when an actor channel is remotely opened for an actor.

Public function Virtual

void

 

NotifyActorDestroyed

(
    AActor* Actor,
    bool IsSeamlessTravel
)

Called when a spawned actor is destroyed.

Public function Virtual

void

 

NotifyActorLevelUnloaded

(
    AActor* Actor
)

Called when an actor is being unloaded during a seamless travel or do due level streaming The main point is that it calls the normal NotifyActorDestroyed to destroy the channel on the server but also removes the Actor reference, sets broken flag, and cleans up actor class references on clients.

Public function Virtual

void

 

NotifyStreamingLevelUnload

(
    ULevel*
)

Public function Virtual

void

 

ProcessLocalClientPackets()

Process any local talker packets that need to be sent to the server

Public function Virtual

void

 

ProcessLocalServerPackets()

Process any local talker packets that need to be sent to clients

Public function Virtual

void

 

ProcessRemoteFunction

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

Process a remote function call on some actor destined for a remote location

Public function Virtual

void

 

SetAnalyticsProvider

(
    TSharedPtr< IAnalyticsProvider > In...
)

Sets the analytics provider

Public function Virtual

void

 

SetWorld

(
    UWorld* InWorld
)

Associate a world with this net driver. Disassociates any previous world first.

Public function Virtual Const

bool

 

ShouldClientDestroyTearOffActors()

Returns true if the client should destroy immediately any actor that becomes torn-off

Public function Virtual Const

bool

 

ShouldForwardFunction

(
    AActor* Actor,
    UFunction* Function,
    void* Parms
)

Returns true if this network driver will forward a received remote function call to other active net drivers.

Public function Virtual Const

bool

 

ShouldIgnoreRPCs()

Returns whether or not RPCs processed by this driver should be ignored.

Public function Virtual Const

bool

 

ShouldQueueBunchesForActorGUID

(
    FNetworkGUID InGUID
)

Returns true if actor channels with InGUID should queue up bunches, even if they wouldn't otherwise be queued.

Public function Virtual Const

bool

 

ShouldReceiveRepNotifiesForObject

(
    UObject* Object
)

Returns true if RepNotifies should be checked and generated when receiving properties for the given object.

Public function Virtual Const

bool

 

ShouldReplicateActor

(
    AActor* Actor
)

Returns true if this network driver will replicate the given actor.

Public function Virtual Const

bool

 

ShouldReplicateFunction

(
    AActor* Actor,
    UFunction* Function
)

Returns true if this network driver will handle the remote function call for the given actor.

Public function Virtual Const

bool

 

ShouldSkipRepNotifies()

Returns whether or not properties that are replicating using this driver should not call RepNotify functions.

Public function Virtual

void

 

TickDispatch

(
    float DeltaTime
)

Handle time update: read and process packets

Public function Virtual

void

 

TickFlush

(
    float DeltaSeconds
)

ReplicateActors and Flush

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.

Constants

Name

Description

OnDemoFailedToStart

Public delegate to be notified when a replay failed to start.

OnDemoStarted

Public delegate for external systems to be notified when a replay begins.

Deprecated Variables

Name Description

Public variable

bool

 

bChannelsArePaused

Please use GetChannelsArePaused instead.

Public variable

bool

 

bIsLocalReplay

No longer used

Public variable

bool

 

bRecordMapChanges

Please use IsRecordingMapChanges() instead.

Public variable

int32

 

CurrentLevelIndex

Please use GetCurrentLevelIndex/SetCurrentLevelIndex instead.

Public variable

TSet< FNetworkG...

 

DeletedNetStartupActorGUIDs

Moved into FReplayHelper

Public variable

TSet< FString >

 

DeletedNetStartupActors

Moved into FReplayHelper

Public variable

float

 

DemoCurrentTime

Please use GetDemoCurrentTime/SetDemoCurrentTime instead.

Public variable

int32

 

DemoFrameNum

Please use GetDemoFrameNum instead.

Public variable

int32

 

DemoTotalFrames

No longer used.

Public variable

float

 

DemoTotalTime

Please use GetDemoTotalTime/SetDemoTotalTime instead.

Public variable

TMap< FNetworkG...

 

ExternalDataToObjectMap

Moved to FReplayHelper.

Public variable

double

 

LastCheckpointTime

Please use GetLastCheckpointTime/SetLastCheckpointTime instead.

Public variable

float

 

OldDemoCurrentTime

No longer used.

Public variable

FOnDemoFinishPl...

 

OnDemoFinishPlaybackDelegate

Moving to FNetworkReplayDelegates.

Public variable

FOnDemoFinishRe...

 

OnDemoFinishRecordingDelegate

Moving to FNetworkReplayDelegates.

Public variable

FOnGotoTimeMCDe...

 

OnGotoTimeDelegate

Moving to FNetworkReplayDelegates.

Public variable

FOnPauseChannel...

 

OnPauseChannelsDelegate

Moving to FNetworkReplayDelegates.

Public variable

TSharedPtr< cla...

 

ReplayStreamer

Please use GetReplayStreamer() instead.

Public variable

TMap< FString, ...

 

RollbackNetStartupActors

Will be made private in a future release.

Public variable

APlayerControll...

 

SpectatorController

Please use GetSpectatorController() instead.

Deprecated Functions

Name Description

Public function

void

 

LoadExternalData

(
    FArchive& Ar,
    const float TimeSeconds
)

Will be removed in a future release.

Public function

void

 

PendingNetGameLoadMapCompleted()

No longer used.

Public function

void

 

SaveCheckpoint()

Will be removed in a future release.

Public function

void

 

SaveExternalData

(
    FArchive& Ar
)

Will be removed in a future release.

Public function Virtual Const

bool

 

ShouldSaveCheckpoint()

Will be removed in a future release.

Public function

void

 

TickCheckpoint()

Will be removed in a future release.

Public function

void

 

WriteDemoFrameFromQueuedDemoPackets

(
    FArchive& Ar,
    TArray< FQueuedDemoPacket >& Queue...,
    float FrameTime
)

WriteDemoFrameFromQueuedDemoPackets now takes an additional flag value

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