fm.liveswitch.ClientStateLedger Class Reference

Maintains a ledger of client state transitions with timestamps. More...

Public Member Functions

 ClientStateLedger (String clientId, String externalId)
 Initializes a new instance of the ClientStateLedger class. More...
 
void recordClientState (fm.liveswitch.ClientState state)
 Records a new client state transition with the current timestamp. More...
 
String toString ()
 Provides a JSON string representation of all recorded state transitions. More...
 

Detailed Description

Maintains a ledger of client state transitions with timestamps.

Tracks and records the history of state changes for a specific client over time.

Constructor & Destructor Documentation

◆ ClientStateLedger()

fm.liveswitch.ClientStateLedger.ClientStateLedger ( String  clientId,
String  externalId 
)

Initializes a new instance of the ClientStateLedger class.

Automatically records an initial "New" state.

Parameters
clientIdThe unique identifier for the client to track.
externalIdThe external identifier for the client. Can be null.

Member Function Documentation

◆ recordClientState()

void fm.liveswitch.ClientStateLedger.recordClientState ( fm.liveswitch.ClientState  state)

Records a new client state transition with the current timestamp.

Adds a new record to the state history with both UTC time and millisecond precision timestamp.

Parameters
stateThe new client state to record.

◆ toString()

String fm.liveswitch.ClientStateLedger.toString ( )

Provides a JSON string representation of all recorded state transitions.

Includes client identification, state transition history with timestamps and elapsed times, and diagnostic information if the client never reached the registered state.

Returns
A JSON formatted string containing the complete state transition history and diagnostics. Returns "{}" if no states have been recorded.