/ fm / liveswitch / ConnectionStateMachine
Class: ConnectionStateMachine
fm.liveswitch.ConnectionStateMachine
A state machine for connection states.
Hierarchy
-
↳ ConnectionStateMachine
Table of contents
Constructors
Methods
- addTransition
- canTransition
- getLastStateMillis
- getLastStateTicks
- getPromise
- getState
- getStateValue
- getSystemTimestamp
- getTypeString
- isReachable
- stateToValue
- transition
- valueToState
Constructors
constructor
+ new ConnectionStateMachine(): ConnectionStateMachine
Initializes a new instance of the [[fm.liveswitch.connectionStateMachine]] class.
Returns: ConnectionStateMachine
Inherited from: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/ConnectionStateMachine.ts:12
Methods
addTransition
▸ addTransition(fromState
: ConnectionState, toState
: ConnectionState): void
Adds an allowed transition.
Parameters:
Name | Type | Description |
---|---|---|
fromState |
ConnectionState | The "from" state. |
toState |
ConnectionState | The "to" state. |
Returns: void
Inherited from: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/StateMachine.ts:85
canTransition
▸ canTransition(toState
: ConnectionState): boolean
Determines whether a transition to the specified state is allowed.
Parameters:
Name | Type | Description |
---|---|---|
toState |
ConnectionState | The "to" state. |
Returns: boolean
true
if a transition to the specified state is allowed; otherwise, false
.
Inherited from: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/StateMachine.ts:118
getLastStateMillis
▸ getLastStateMillis(): number
Gets the length of time spent in the last state, in milliseconds.
Returns: number
Inherited from: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/StateMachine.ts:183
getLastStateTicks
▸ getLastStateTicks(): number
Gets the length of time spent in the last state, in ticks.
Returns: number
Inherited from: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/StateMachine.ts:200
getPromise
▸ getPromise<R>(state
: ConnectionState, returnValue
: R): Promise<R>
Gets a promise, which may be resolved or rejected depending on the current state of this machine.
Type parameters:
Name | Type |
---|---|
R |
Object |
Parameters:
Name | Type | Description |
---|---|---|
state |
ConnectionState | State, in which promise must be resolved. |
returnValue |
R | Return type of this promise. |
Returns: Promise<R>
Promise, which may be resolved or rejected depending on the current state of this machine
Inherited from: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/StateMachine.ts:215
getState
▸ getState(): ConnectionState
Gets the state.
Returns: ConnectionState
Inherited from: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/StateMachine.ts:238
getStateValue
▸ Protected
getStateValue(): number
Gets the state value.
Returns: number
Inherited from: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/StateMachine.ts:250
getSystemTimestamp
▸ getSystemTimestamp(): number
Gets the system timestamp of the last state transition.
Returns: number
Inherited from: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/StateMachine.ts:263
getTypeString
▸ getTypeString(): string
Returns: string
Overrides: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/ConnectionStateMachine.ts:10
isReachable
▸ isReachable(state
: ConnectionState): boolean
Determines whether a transition to a specified state is possible (even via intermediate hops).
Parameters:
Name | Type | Description |
---|---|---|
state |
ConnectionState | The "to" state. |
Returns: boolean
true
if a transition to the specified state is possible; otherwise, false
.
Inherited from: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/StateMachine.ts:278
stateToValue
▸ Protected
stateToValue(state
: ConnectionState): number
Converts a state to an integer value.
Parameters:
Name | Type | Description |
---|---|---|
state |
ConnectionState | The state. |
Returns: number
Overrides: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/ConnectionStateMachine.ts:49
transition
▸ transition(toState
: ConnectionState): boolean
Transitions to the specified state.
Parameters:
Name | Type | Description |
---|---|---|
toState |
ConnectionState | The "to" state. |
Returns: boolean
true
if a transition to the specified state is allowed; otherwise, false
.
Inherited from: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/StateMachine.ts:333
valueToState
▸ Protected
valueToState(value
: number): ConnectionState
Converts an integer value to a state.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | The integer value. |
Returns: ConnectionState
Overrides: StateMachine
Defined in: Generated/TypeScript/fm.liveswitch/ConnectionStateMachine.ts:62