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

Public variable

bool

 

bChannelsArePaused

True if as have paused all of the channels

Public variable

bool

 

bIsLocalReplay

Protected variable

bool

 

bIsWaitingForHeaderDownload

Protected variable

bool

 

bIsWaitingForStream

Public variable

bool

 

bRecordMapChanges

Public variable

int32

 

CurrentLevelIndex

Index of LevelNames that is currently loaded

Public variable

TSet< FNetworkGUID >

 

DeletedNetStartupActorGUIDs

Keeps track of NetGUIDs that were deleted, so we can skip them when saving checkpoints.

Public variable

TSet< FString >

 

DeletedNetStartupActors

Net startup actors that need to be destroyed after checkpoints are loaded

Public variable

float

 

DemoCurrentTime

Current record/playback position in seconds

Public variable

int32

 

DemoFrameNum

Current record/playback frame number

Public variable

int32

 

DemoTotalFrames

Total number of frames in the demo

Public variable

float

 

DemoTotalTime

Total time of demo in seconds

Public variable

TMap< FNetworkGUID, FReplayExternalDataArray >

 

ExternalDataToObjectMap

ExternalDataToObjectMap is used to map a FNetworkGUID to the proper FReplayExternalDataArray

Public variable

double

 

LastCheckpointTime

Public variable

double

 

LastRecordAvgFlush

Protected variable

int64

 

MaxArchiveReadPos

Public variable

double

 

MaxRecordTime

Public variable

TSet< TWeakObjectPtr< UObject > >

 

NewStreamingLevelsThisFrame

During recording, streaming levels waiting to be saved next frame.

Public variable

float

 

OldDemoCurrentTime

Old current record/playback position in seconds (so we can restore on checkpoint failure)

Public variable

FOnDemoFinishPlaybackDelegate

 

OnDemoFinishPlaybackDelegate

Delegate for external systems to be notified when demo playback ends

Public variable

FOnDemoFinishRecordingDelegate

 

OnDemoFinishRecordingDelegate

Public Delegate for external systems to be notified when replay recording is about to finish.

Public variable

FOnGotoTimeMCDelegate

 

OnGotoTimeDelegate

Public delegate for external systems to be notified when scrubbing is complete.

Public variable

FOnPauseChannelsDelegate

 

OnPauseChannelsDelegate

Delegate for external systems to be notified when channels are paused during playback, usually waiting for data to be available.

Public variable

TArray< FPlaybackPacket >

 

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< FQueuedDemoPacket >

 

QueuedPacketsBeforeTravel

Public variable

int32

 

RecordCountSinceFlush

Public variable

TSharedPtr< class INetworkReplayStreamer >

 

ReplayStreamer

Our network replay streamer

Public variable

TMap< FString, FRollbackNetStartupActorInfo >

 

RollbackNetStartupActors

Net startup actors that need to be rolled back during scrubbing by being destroyed and re-spawned NOTE - DeletedNetStartupActors will take precedence here, and destroy the actor instead

Public variable

APlayerController *

 

SpectatorController

This is the main spectator controller that is used to view the demo world from

Public variable

TSet< TWeakObjectPtr< UObject > >

 

UniqueStreamingLevels

During recording, all unique streaming levels since recording started.

Constructors

Name Description

Public function

UDemoNetDriver

(
    const FObjectInitializer& ObjectInitializer
)

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& State
)

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& Delegate
)

Public function

void

 

EnumerateEventsForActiveReplay

(
    const FString& Group,
    const int32 UserIndex,
    const FEnumerateEventsCallback& Delegate
)

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& Delegate
)

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 FString &

 

GetActiveReplayName()

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

Public function Const

float

 

GetDemoCurrentTime()

Current record/playback position in seconds

Public function Const

uint32

 

GetDemoCurrentTimeInMS()

Public function Const

FString

 

GetDemoPath()

Public function Const

const FString &

 

GetDemoSessionID()

Public function Const

float

 

GetDemoTotalTime()

Total time of demo in seconds

Public function Const

FString

 

GetDemoURL()

Public function

FReplayExternalDataArray *

 

GetExternalDataArrayForObject

(
    UObject* Object
)

Public function

const TArray< FLevelNameAndTime > &

 

GetLevelNameAndTimeList()

Public function Const

FName

 

GetNextQueuedTaskName()

Public function Const

uint32

 

GetPlaybackDemoVersion()

Public function

void

 

GotoTimeInSeconds

(
    const float TimeInSeconds,
    const FOnGotoTimeDelegate& InOnGotoTimeDelegate
)

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

 

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

 

IsRecordingPaused()

Public function Const

bool

 

IsSavingCheckpoint()

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

Public function

void

 

JumpToEndOfLiveReplay()

Public function

void

 

LoadExternalData

(
    FArchive& Ar,
    const float TimeSeconds
)

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

 

PendingNetGameLoadMapCompleted()

Read the streaming level information from the metadata after the level is loaded

Public function

void

 

ProcessAllPlaybackPackets()

Protected function Virtual

bool

 

ProcessGameSpecificDemoHeader

(
    const TArray< FString >& GameSpecificData,
    FString& Error
)

Allows subclasses to read game specific data from demo return false to cancel playback

Public function

bool

 

ProcessPacket

(
    const FPlaybackPacket& PlaybackPacket
)

Public function

bool

 

ProcessPacket

(
    const uint8* Data,
    int32 Count
)

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
)

Protected function

bool

 

ReadPlaybackDemoHeader

(
    FString& Error
)

Public function

bool

 

RemoveSplitscreenViewer

(
    APlayerController* RemovePlayer,
    bool bMarkOwnerForDeletion
)

Removes a splitscreen demo viewer and cleans up its connection.

Public function

void

 

ReplayStreamingReady

(
    const FStartStreamingResult& Result
)

Public function

void

 

RequestEventData

(
    const FString& EventID,
    const FRequestEventDataCallback& Delegate
)

Public function

void

 

RequestEventDataForActiveReplay

(
    const FString& EventID,
    const int32 UserIndex,
    const FRequestEventDataCallback& Delegate
)

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& Delegate
)

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 FRequestEventGroupDataCallback& Delegate
)

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 int32 UserIndex,
    const FRequestEventGroupDataCallback& Delegate
)

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* >& SpawnedActors,
    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

void

 

SaveCheckpoint()

Public function

void

 

SaveExternalData

(
    FArchive& Ar
)

Public function Const

FDemoSavedPropertyState

 

SavePropertyState()

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

Protected function

void

 

SerializeGuidCache

(
    TSharedPtr< class FNetGUIDCache > GuidCache,
    FArchive* CheckpointArchive
)

Public function

void

 

SetActorPrioritizationEnabled

(
    const bool bInPrioritizeActors
)

Enable or disable prioritization of actors for recording.

Public function

void

 

SetCheckpointSaveMaxMSPerFrame

(
    const float InCheckpointSaveMaxMSPerFrame
)

Sets CheckpointSaveMaxMSPerFrame.

Public function

void

 

SetMaxDesiredRecordTimeMS

(
    const float InMaxDesiredRecordTimeMS
)

Sets the desired maximum recording time in milliseconds.

Public function

void

 

SetPlayingPlaylist

(
    TSharedPtr< struct FReplayPlaylistTracker > InPlaylistTracker
)

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 InViewerOverride
)

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

Public function Virtual Const

bool

 

ShouldSaveCheckpoint()

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

 

TickCheckpoint()

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 >& QueuedPackets,
    float FrameTime
)

Protected function Virtual

void

 

WriteGameSpecificDemoHeader

(
    TArray< FString >& GameSpecificData
)

Allows subclasses to write game specific data to demo header which is then handled by ProcessGameSpecificDemoHeader

Protected function

bool

 

WriteNetworkDemoHeader

(
    FString& Error
)

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

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* InConnection
)

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

 

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 > InProvider
)

Sets the analytics provider

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

 

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.

Enums

Name

Description

Private enum

ECheckpointSaveState

Private enum

EReadPacketMode

Private enum

EReadPacketState

Possible values returned by ReadPacket.

Typedefs

Name

Description

FArchivePos

The type we use to store offsets in the archive.

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.

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