Table of Contents

Interface IRollbackHandler<TState>

Namespace
Backdash
Assembly
Backdash.dll

The SessionCallbacks contains the callback functions that your application must implement. Backdash will periodically call these functions during the game. All callback functions must be implemented.

public interface IRollbackHandler<TState> where TState : notnull

Type Parameters

TState

Game state type

Methods

AdvanceFrame()

Called during a rollback after LoadState(in Frame, in TState). You should advance your game state by exactly one frame. Before each frame, call SynchronizeInputs() to retrieve the inputs you should use for that frame. After each frame, you should call AdvanceFrame() to notify Backdash that you're finished.

void AdvanceFrame()

ClearState(ref TState)

Optionally clear the state in buffer before SaveState(in Frame, ref TState).

void ClearState(ref TState gameState)

Parameters

gameState TState

LoadState(in Frame, in TState)

Backdash will call this function at the beginning of a rollback. The client must copy the gameState to the game current state.

void LoadState(in Frame frame, in TState gameState)

Parameters

frame Frame

The loading frame

gameState TState

The game state that must be loaded

OnPeerEvent(PlayerHandle, PeerEventInfo)

Notification that some PeerEvent has happened for a PlayerHandle

void OnPeerEvent(PlayerHandle player, PeerEventInfo evt)

Parameters

player PlayerHandle

The player owner of the event

evt PeerEventInfo

Event data

OnSessionClose()

Called at the end of a game session, before release resources.

void OnSessionClose()

OnSessionStart()

Called at start of a game session, when all the clients have synchronized. You may begin sending inputs with.

void OnSessionStart()

SaveState(in Frame, ref TState)

The client should copy the entire contents of the current game state into state.

void SaveState(in Frame frame, ref TState state)

Parameters

frame Frame

The frame which the save occurs.

state TState

The pre-buffered state reference to be filled.

TimeSync(FrameSpan)

The time synchronization has determined that this client is too far ahead of the other one and should slow down to ensure fairness.

void TimeSync(FrameSpan framesAhead)

Parameters

framesAhead FrameSpan

Indicates how many frames the client is ahead