Options
All
  • Public
  • Public/Protected
  • All
Menu

Enumeration CONNECTION_STATE_TYPE

Connection states.

  • 1: The SDK is disconnected from Agora's edge server.
  • 2: The SDK is connecting to Agora's edge server. When the application calls the AgoraRtcEngine.joinChannel method, the SDK starts to establish a connection to the specified channel.
    • When the SDK successfully joins the channel, it triggers the connectionStateChanged callback and switches to the 3 state.
    • After the SDK joins the channel and when it finishes initializing the media engine, the SDK triggers the joinedChannel callback.
  • 3: The SDK is connected to Agora's edge server and has joined a channel. You can now publish or subscribe to a media stream in the channel.If the connection to the channel is lost because, for example, if the network is down or switched, the SDK automatically tries to reconnect and triggers:
    • The connectionStateChanged callback and switches to the 4 state.
  • 4: The SDK keeps rejoining the channel after being disconnected from a joined channel because of network issues.
    • If the SDK cannot rejoin the channel within 10 seconds after being disconnected from Agora's edge server, the SDK triggers the connectionLost callback, stays in this state, and keeps rejoining the channel.
    • If the SDK fails to rejoin the channel 20 minutes after being disconnected from Agora's edge server, the SDK triggers the connectionStateChanged callback, switches to the 5 state, and stops rejoining the channel.
  • 5: The SDK fails to connect to Agora's edge server or join the channel. You must call the leaveChannel method to leave this state.
    • Calls the joinChannel method again to rejoin the channel.
    • If the SDK is banned from joining the channel by Agora's edge server (through the RESTful API), the SDK triggers connectionStateChanged callbacks.

Index

Enumeration members

CONNECTION_STATE_CONNECTED

CONNECTION_STATE_CONNECTED: = 3

3: The SDK is connected to Agora's edge server and has joined a channel. You can now publish or subscribe to a media stream in the channel.

If the connection to the channel is lost because, for example, if the network is down or switched, the SDK automatically tries to reconnect and triggers:

  • The \ref agora::rtc::IRtcEngineEventHandler::onConnectionInterrupted "onConnectionInterrupted" callback (deprecated).
  • The \ref agora::rtc::IRtcEngineEventHandler::onConnectionStateChanged "onConnectionStateChanged" callback and switches to the #CONNECTION_STATE_RECONNECTING state.

CONNECTION_STATE_CONNECTING

CONNECTION_STATE_CONNECTING: = 2

2: The SDK is connecting to Agora's edge server.

  • When the application calls the \ref agora::rtc::IRtcEngine::joinChannel "joinChannel" method, the SDK starts to establish a connection to the specified channel, triggers the \ref agora::rtc::IRtcEngineEventHandler::onConnectionStateChanged "onConnectionStateChanged" callback, and switches to the #CONNECTION_STATE_CONNECTING state.
  • When the SDK successfully joins the channel, it triggers the \ref agora::rtc::IRtcEngineEventHandler::onConnectionStateChanged "onConnectionStateChanged" callback and switches to the #CONNECTION_STATE_CONNECTED state.
  • After the SDK joins the channel and when it finishes initializing the media engine, the SDK triggers the \ref agora::rtc::IRtcEngineEventHandler::onJoinChannelSuccess "onJoinChannelSuccess" callback.

CONNECTION_STATE_DISCONNECTED

CONNECTION_STATE_DISCONNECTED: = 1

1: The SDK is disconnected from Agora's edge server.

  • This is the initial state before calling the \ref agora::rtc::IRtcEngine::joinChannel "joinChannel" method.
  • The SDK also enters this state when the application calls the \ref agora::rtc::IRtcEngine::leaveChannel "leaveChannel" method.

CONNECTION_STATE_FAILED

CONNECTION_STATE_FAILED: = 5

5: The SDK fails to connect to Agora's edge server or join the channel.

You must call the \ref agora::rtc::IRtcEngine::leaveChannel "leaveChannel" method to leave this state, and call the \ref agora::rtc::IRtcEngine::joinChannel "joinChannel" method again to rejoin the channel.

If the SDK is banned from joining the channel by Agora's edge server (through the RESTful API), the SDK triggers the \ref agora::rtc::IRtcEngineEventHandler::onConnectionBanned "onConnectionBanned" (deprecated) and \ref agora::rtc::IRtcEngineEventHandler::onConnectionStateChanged "onConnectionStateChanged" callbacks.

CONNECTION_STATE_RECONNECTING

CONNECTION_STATE_RECONNECTING: = 4

4: The SDK keeps rejoining the channel after being disconnected from a joined channel because of network issues.

  • If the SDK cannot rejoin the channel within 10 seconds after being disconnected from Agora's edge server, the SDK triggers the \ref agora::rtc::IRtcEngineEventHandler::onConnectionLost "onConnectionLost" callback, stays in the #CONNECTION_STATE_RECONNECTING state, and keeps rejoining the channel.
  • If the SDK fails to rejoin the channel 20 minutes after being disconnected from Agora's edge server, the SDK triggers the \ref agora::rtc::IRtcEngineEventHandler::onConnectionStateChanged "onConnectionStateChanged" callback, switches to the #CONNECTION_STATE_FAILED state, and stops rejoining the channel.