Understand the DirectLineJS state machine
masterDirectLineJS operates as a state machine where the current state is defined by the connectionStatus$ observable. Understanding these states is critical for managing connection lifecycles and error handling:
- Uninitialized: The initial state after calling
new DirectLine(). - Connecting: The adapter is attempting to establish a connection. This state includes automatic retries with backoff.
- Online: The connection is established. A connection is considered "stable" after being in this state for more than 1 minute, which resets the retry counter and removes backoff on the first retry attempt after a subsequent disconnection.
- FailedToConnect: The state reached when all retry attempts are exhausted.
- Ended: The terminal state reached after calling
end(). All resources are released, andactivity$andconnectionStatus$observables are completed.