FMLiveSwitchStateMachine Class Reference

A simple state machine. More...

Instance Methods

(bool) - canTransitionWithToState:
 Determines whether a transition to the specified state is allowed. More...
 
(FMLiveSwitchPromise< id > *) - getPromiseWithState:returnValue:
 Gets a promise, which may be resolved or rejected depending on the current state of this machine. More...
 
(instancetype) - initWithInitialState:
 Initializes a new instance of the FMLiveSwitchStateMachine`1 class. More...
 
(bool) - isReachableWithState:
 Determines whether a transition to a specified state is possible (even via intermediate hops). More...
 
(long long) - lastStateMillis
 Gets the length of time spent in the last state, in milliseconds. More...
 
(long long) - lastStateTicks
 Gets the length of time spent in the last state, in ticks. More...
 
(T) - state
 Gets the state. More...
 
(int) - stateToValueWithState:
 Converts a state to an integer value. More...
 
(int) - stateValue
 Gets the state value. More...
 
(long long) - systemTimestamp
 Gets the system timestamp of the last state transition. More...
 
(bool) - transitionWithToState:
 Transitions to the specified state. More...
 
(T) - valueToState:
 Converts an integer value to a state. More...
 

Class Methods

(FMLiveSwitchStateMachine *) + stateMachineWithInitialState:
 Initializes a new instance of the FMLiveSwitchStateMachine`1 class. More...
 

Protected Attributes

 __pad0__: NSObject- (void) addTransitionWithFromState:(T)fromState toState:(T)toState
 

Detailed Description

A simple state machine.

Method Documentation

◆ canTransitionWithToState:

- (bool) canTransitionWithToState: (T)  toState

Determines whether a transition to the specified state is allowed.

Parameters
toStateThe "to" state.
Returns
true if a transition to the specified state is allowed; otherwise, false.

◆ getPromiseWithState:returnValue:

- (FMLiveSwitchPromise<id>*) getPromiseWithState: (T)  state
returnValue: (id returnValue 

Gets a promise, which may be resolved or rejected depending on the current state of this machine.

Parameters
stateState, in which promise must be resolved.
returnValueReturn type of this promise.
Returns
Promise, which may be resolved or rejected depending on the current state of this machine

◆ initWithInitialState:

- (instancetype) initWithInitialState: (T)  initialState

Initializes a new instance of the FMLiveSwitchStateMachine`1 class.

Parameters
initialStateThe initial state.

◆ isReachableWithState:

- (bool) isReachableWithState: (T)  state

Determines whether a transition to a specified state is possible (even via intermediate hops).

Parameters
stateThe "to" state.
Returns
true if a transition to the specified state is possible; otherwise, false.

◆ lastStateMillis

- (long long) lastStateMillis

Gets the length of time spent in the last state, in milliseconds.

◆ lastStateTicks

- (long long) lastStateTicks

Gets the length of time spent in the last state, in ticks.

◆ state

- T state

Gets the state.

◆ stateMachineWithInitialState:

+ (FMLiveSwitchStateMachine*) stateMachineWithInitialState: (T)  initialState

Initializes a new instance of the FMLiveSwitchStateMachine`1 class.

Parameters
initialStateThe initial state.

◆ stateToValueWithState:

- (int) stateToValueWithState: (T)  state

Converts a state to an integer value.

Parameters
stateThe state.

◆ stateValue

- (int) stateValue

Gets the state value.

◆ systemTimestamp

- (long long) systemTimestamp

Gets the system timestamp of the last state transition.

◆ transitionWithToState:

- (bool) transitionWithToState: (T)  toState

Transitions to the specified state.

Parameters
toStateThe "to" state.
Returns
true if a transition to the specified state is allowed; otherwise, false.

◆ valueToState:

- T valueToState: (int)  value

Converts an integer value to a state.

Parameters
valueThe integer value.

Implemented in FMLiveSwitchStreamStateMachine, FMLiveSwitchDataChannelStateMachine, FMLiveSwitchConnectionStateMachine, and FMLiveSwitchClientStateMachine.

Member Data Documentation

◆ __pad0__

- __pad0__
protected