AgoraConnectionStateType Constants Reference

Declared in AgoraEnumerates.h

AgoraConnectionStateType

Connection states.

Definition

typedef NS_ENUM(NSInteger, AgoraConnectionStateType ) {
   AgoraConnectionStateDisconnected = 1,
   AgoraConnectionStateConnecting = 2,
   AgoraConnectionStateConnected = 3,
   AgoraConnectionStateReconnecting = 4,
   AgoraConnectionStateFailed = 5,
};

Constants

AgoraConnectionStateDisconnected

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

  • This is the initial state before joinChannelByToken.
  • The SDK also enters this state when the app calls leaveChannel.

    Declared In AgoraEnumerates.h.

  • AgoraConnectionStateConnecting

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

    When the app calls joinChannelByToken, the SDK starts to establish a connection to the specified channel, triggers the connectionChangedToState callback, and switches to the AgoraConnectionStateConnecting state.

    When the SDK successfully joins the channel, the SDK triggers the connectionChangedToState callback and switches to the AgoraConnectionStateConnected state.

    After the SDK joins the channel and when it finishes initializing the media engine, the SDK triggers the didJoinChannel callback.

    Declared In AgoraEnumerates.h.

    AgoraConnectionStateConnected

    3: The SDK is connected to Agora's edge server and joins 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, the network is down or switched, the SDK automatically tries to reconnect and triggers:

  • The rtcEngineConnectionDidInterrupted(deprecated) callback
  • The connectionChangedToState callback, and switches to the AgoraConnectionStateReconnecting state.

    Declared In AgoraEnumerates.h.

  • AgoraConnectionStateReconnecting

    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 rtcEngineConnectionDidLost callback, stays in the AgoraConnectionStateReconnecting 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 connectionChangedToState callback, switches to the AgoraConnectionStateFailed state, and stops rejoining the channel.

    Declared In AgoraEnumerates.h.

  • AgoraConnectionStateFailed

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

  • You must call leaveChannel to leave this state, and call joinChannelByToken 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 rtcEngineConnectionDidBanned(deprecated) and connectionChangedToState callbacks.

    Declared In AgoraEnumerates.h.

  • Declared In

    AgoraEnumerates.h