Search Results for

    Show / Hide Table of Contents

    Class StateMachine<T>

    A simple state machine.

    Inheritance
    System.Object
    StateMachine<T>
    ClientStateMachine
    ConnectionStateMachine
    DataChannelStateMachine
    StreamStateMachine
    Namespace: FM.LiveSwitch
    Assembly: FM.LiveSwitch.dll
    Syntax
    public abstract class StateMachine<T> : object
    Type Parameters
    Name Description
    T

    Constructors

    StateMachine(T)

    Initializes a new instance of the StateMachine<T> class.

    Declaration
    public StateMachine(T initialState)
    Parameters
    Type Name Description
    T initialState

    The initial state.

    Properties

    LastStateMillis

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

    Declaration
    public long LastStateMillis { get; }
    Property Value
    Type Description
    System.Int64

    LastStateTicks

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

    Declaration
    public long LastStateTicks { get; }
    Property Value
    Type Description
    System.Int64

    State

    Gets the state.

    Declaration
    public T State { get; }
    Property Value
    Type Description
    T

    StateValue

    Gets the state value.

    Declaration
    protected int StateValue { get; }
    Property Value
    Type Description
    System.Int32

    SystemTimestamp

    Gets the system timestamp of the last state transition.

    Declaration
    public long SystemTimestamp { get; }
    Property Value
    Type Description
    System.Int64

    Methods

    AddTransition(T, T)

    Adds an allowed transition.

    Declaration
    public void AddTransition(T fromState, T toState)
    Parameters
    Type Name Description
    T fromState

    The "from" state.

    T toState

    The "to" state.

    CanTransition(T)

    Determines whether a transition to the specified state is allowed.

    Declaration
    public bool CanTransition(T toState)
    Parameters
    Type Name Description
    T toState

    The "to" state.

    Returns
    Type Description
    System.Boolean

    true if a transition to the specified state is allowed; otherwise, false.

    GetPromise<R>(T, R)

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

    Declaration
    public Promise<R> GetPromise<R>(T state, R returnValue)
        where R : class
    Parameters
    Type Name Description
    T state

    State, in which promise must be resolved.

    R returnValue

    Return type of this promise.

    Returns
    Type Description
    Promise<R>

    Promise, which may be resolved or rejected depending on the current state of this machine

    Type Parameters
    Name Description
    R

    IsReachable(T)

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

    Declaration
    public bool IsReachable(T state)
    Parameters
    Type Name Description
    T state

    The "to" state.

    Returns
    Type Description
    System.Boolean

    true if a transition to the specified state is possible; otherwise, false.

    StateToValue(T)

    Converts a state to an integer value.

    Declaration
    protected abstract int StateToValue(T state)
    Parameters
    Type Name Description
    T state

    The state.

    Returns
    Type Description
    System.Int32

    Transition(T)

    Transitions to the specified state.

    Declaration
    public bool Transition(T toState)
    Parameters
    Type Name Description
    T toState

    The "to" state.

    Returns
    Type Description
    System.Boolean

    true if a transition to the specified state is allowed; otherwise, false.

    ValueToState(Int32)

    Converts an integer value to a state.

    Declaration
    protected abstract T ValueToState(int value)
    Parameters
    Type Name Description
    System.Int32 value

    The integer value.

    Returns
    Type Description
    T
    In This Article
    Back to top Copyright © LiveSwitch Inc. All Rights Reserved. Doc build for LiveSwitch v1.15.0