ConnectionStateType
Network connection state.
Enumerations
- ConnectionStateDisconnected
- 1: Network connection is disconnected. This state indicates that the SDK is in:
- The initialization phase before calling joinChannel to join a channel.
- Or the phase after calling leaveChannel to leave a channel.
- ConnectionStateConnecting
- 2: Connecting to the network. This state indicates that the SDK is establishing a connection with the specified channel after calling joinChannel.
- If the channel is joined successfully, the app receives the onConnectionStateChanged callback, indicating the network state has changed to ConnectionStateConnected.
- After the connection is established, the SDK initializes media and triggers the onJoinChannelSuccess callback once everything is ready.
- ConnectionStateConnected
- 3: Network is connected. This state indicates that the user has joined the channel and can publish or subscribe to media streams. If the connection is interrupted due to network disconnection or switching, the SDK automatically reconnects. The app receives the onConnectionStateChanged callback, indicating the network state has changed to ConnectionStateReconnecting.
- ConnectionStateReconnecting
- 4: Reconnecting to the network. This state indicates that the SDK had previously joined a channel but the connection was interrupted due to network issues. The SDK is now trying to reconnect to the channel.
- If the SDK cannot rejoin the channel within 10 seconds, onConnectionLost is triggered. The SDK remains in the ConnectionStateReconnecting state and continues trying to rejoin.
- If the SDK still cannot rejoin the channel within 20 minutes after disconnection, the app receives the onConnectionStateChanged callback, indicating that the network state has changed to ConnectionStateFailed, and the SDK stops trying to reconnect.
- ConnectionStateFailed
- 5: Network connection failed. This state indicates that the SDK has stopped trying to rejoin the channel and you need to call leaveChannel to leave the channel.
- If the user wants to rejoin the channel, they need to call joinChannel again.
- If the SDK is prohibited from joining the channel by the server using RESTful API, the app will receive onConnectionStateChanged.