swift-api-client/Sources/MessagingAPIClient/WebSocket/ConnectionState.swift

29 lines
897 B
Swift

import Foundation
// MARK: - WebSocket Connection State
/// Represents the current state of the WebSocket connection lifecycle.
///
/// State transitions:
/// ```
/// disconnected -> connecting -> connected
/// |
/// v
/// reconnecting -> connecting -> connected
/// |
/// v
/// disconnected (after max retries or explicit disconnect)
/// ```
public enum WSConnectionState: String, Sendable, Hashable {
/// Not connected to the server.
case disconnected
/// Actively establishing a connection.
case connecting
/// Connected and ready to send/receive events.
case connected
/// Connection lost; attempting automatic reconnection with exponential backoff.
case reconnecting
}