Agora RTC Objective-C API Reference Refactor

Public Member Functions
IRtcConnectionObserver Class Referenceabstract

## Public Member Functions
virtual void | onConnected (const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual void | onDisconnected (const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual void | onConnecting (const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual void | onReconnecting (const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual void | onConnectionLost (const TConnectionInfo &connectionInfo)=0
virtual void | onLastmileQuality (const QUALITY_TYPE quality)=0
virtual void | onLastmileProbeResult (const LastmileProbeResult &result)=0
virtual void | onTokenPrivilegeWillExpire (const char *token)=0
virtual void | onTokenPrivilegeDidExpire ()=0
virtual void | onRenewTokenResult (const char *token, RENEW_TOKEN_ERROR_CODE code)=0
virtual void | onConnectionFailure (const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual void | onUserJoined (user_id_t userId)=0
virtual void | onUserLeft (user_id_t userId, USER_OFFLINE_REASON_TYPE reason)=0
virtual void | onTransportStats (const RtcStats &stats)=0
virtual void | onChangeRoleSuccess (CLIENT_ROLE_TYPE oldRole, CLIENT_ROLE_TYPE newRole, const ClientRoleOptions &newRoleOptions)
virtual void | onChangeRoleFailure (CLIENT_ROLE_CHANGE_FAILED_REASON reason, CLIENT_ROLE_TYPE currentRole)
virtual void | onLicenseValidationFailure (LICENSE_ERROR_TYPE error)
virtual void | onUserNetworkQuality (user_id_t userId, QUALITY_TYPE txQuality, QUALITY_TYPE rxQuality)
virtual void | onNetworkTypeChanged (NETWORK_TYPE type)
virtual void | onContentInspectResult (media::CONTENT_INSPECT_RESULT result)
virtual void | onSnapshotTaken (user_id_t userId, const char *filePath, int width, int height, int errCode)
virtual void | onError (ERROR_CODE_TYPE error, const char *msg)
virtual void | onChannelMediaRelayStateChanged (int state, int code)=0
virtual void | onLocalUserRegistered (uid_t uid, const char *userAccount)
virtual void | onUserAccountUpdated (uid_t uid, const char *userAccount)
virtual void | onStreamMessageError (user_id_t userId, int streamId, int code, int missed, int cached)
virtual void | onEncryptionError (ENCRYPTION_ERROR_TYPE errorType)
virtual void | onUploadLogResult (const char *requestId, bool success, UPLOAD_ERROR_REASON reason)
virtual void | onSetRtmFlagResult (int code)
virtual void | onMultipathStats (const MultipathStats &stats)

## Detailed Description

The IRtcConnectionObserver class, which observes the connection state of the SDK.

## Constructor & Destructor Documentation

## ◆ ~IRtcConnectionObserver()

virtual ~IRtcConnectionObserver | ( |  | ) |
| inline virtual

## Member Function Documentation

## ◆ onConnected()

virtual void onConnected | ( | const TConnectionInfo & | connectionInfo,
|  | CONNECTION_CHANGED_REASON_TYPE | reason
| ) |  |
| pure virtual

Occurs when the connection state between the SDK and the Agora channel changes to `CONNECTION_STATE_CONNECTED(3)`.

Parameters

  connectionInfo | The information of the connection. See TConnectionInfo.
  reason | The reason of the connection state change. See CONNECTION_CHANGED_REASON_TYPE.

## ◆ onDisconnected()

virtual void onDisconnected | ( | const TConnectionInfo & | connectionInfo,
|  | CONNECTION_CHANGED_REASON_TYPE | reason
| ) |  |
| pure virtual

Occurs when the connection state between the SDK and the Agora channel changes to `CONNECTION_STATE_DISCONNECTED(1)`.

Parameters

  connectionInfo | The information of the connection. See TConnectionInfo.
  reason | The reason of the connection state change. See CONNECTION_CHANGED_REASON_TYPE.

## ◆ onConnecting()

virtual void onConnecting | ( | const TConnectionInfo & | connectionInfo,
|  | CONNECTION_CHANGED_REASON_TYPE | reason
| ) |  |
| pure virtual

Occurs when the connection state between the SDK and the Agora channel changes to `CONNECTION_STATE_CONNECTING(2)`.

Parameters

  connectionInfo | The information of the connection. See TConnectionInfo.
  reason | The reason of the connection state change. See CONNECTION_CHANGED_REASON_TYPE.

## ◆ onReconnecting()

virtual void onReconnecting | ( | const TConnectionInfo & | connectionInfo,
|  | CONNECTION_CHANGED_REASON_TYPE | reason
| ) |  |
| pure virtual

Occurs when the connection state between the SDK and the Agora channel changes to `CONNECTION_STATE_RECONNECTING(4)`.

Parameters

  connectionInfo | The information of the connection. See TConnectionInfo.
  reason | The reason of the connection state change. See CONNECTION_CHANGED_REASON_TYPE.

## ◆ onReconnected()

virtual void onReconnected | ( | const TConnectionInfo & | connectionInfo,
|  | CONNECTION_CHANGED_REASON_TYPE | reason
| ) |  |
| pure virtual

## ◆ onConnectionLost()

virtual void onConnectionLost | ( | const TConnectionInfo & | connectionInfo | ) |
| pure virtual

Occurs when the SDK loses connection with the Agora channel.

Parameters

  connectionInfo | The information of the connection. See TConnectionInfo.

## ◆ onLastmileQuality()

virtual void onLastmileQuality | ( | const QUALITY_TYPE | quality | ) |
| pure virtual

Reports the quality of the last-mile network.

The SDK triggers this callback within two seconds after the app calls startLastmileProbeTest.

Parameters

  quality | Quality of the last-mile network: QUALITY_TYPE.

## ◆ onLastmileProbeResult()

virtual void onLastmileProbeResult | ( | const LastmileProbeResult & | result | ) |
| pure virtual

Reports the result of the last-mile network probe test.

The SDK triggers this callback within 30 seconds after the app calls startLastmileProbeTest.

Parameters

  result | The result of the last-mile network probe test: LastmileProbeResult.

## ◆ onTokenPrivilegeWillExpire()

virtual void onTokenPrivilegeWillExpire | ( | const char * | token | ) |
| pure virtual

Occurs when the token expires in 30 seconds.

The SDK triggers this callback to remind the app to get a new token before the token privilege expires.

Upon receiving this callback, you must generate a new token on your server and call renewToken to pass the new token to the SDK.

Parameters

  token | The pointer to the token that expires in 30 seconds.

## ◆ onTokenPrivilegeDidExpire()

virtual void onTokenPrivilegeDidExpire | ( |  | ) |
| pure virtual

Occurs when the token has expired.

Upon receiving this callback, you must generate a new token on your server and call renewToken to pass the new token to the SDK.

## ◆ onRenewTokenResult()

virtual void onRenewTokenResult | ( | const char * | token,
|  | RENEW_TOKEN_ERROR_CODE | code
| ) |  |
| pure virtual

Reports the result of calling renewToken.

Since
  v4.6.0

Occurs when a user renews the token.

This callback notifies the app of the result after the user calls `renewToken` to renew the token. The app can obtain the result of the `renewToken` call from this callback.

Parameters

  token | The token.
  code | The error code.

## ◆ onConnectionFailure()

virtual void onConnectionFailure | ( | const TConnectionInfo & | connectionInfo,
|  | CONNECTION_CHANGED_REASON_TYPE | reason
| ) |  |
| pure virtual

Occurs when the connection state between the SDK and the Agora channel changes to `CONNECTION_STATE_FAILED(5)`.

Parameters

  connectionInfo | The connection information: TConnectionInfo.
  reason | The reason of the connection state change: CONNECTION_CHANGED_REASON_TYPE.

## ◆ onUserJoined()

virtual void onUserJoined | ( | user_id_t | userId | ) |
| pure virtual

Occurs when a remote user joins the channel.

You can get the ID of the remote user in this callback.

Parameters

  userId | The ID of the remote user who joins the channel.

## ◆ onUserLeft()

virtual void onUserLeft | ( | user_id_t | userId,
|  | USER_OFFLINE_REASON_TYPE | reason
| ) |  |
| pure virtual

Occurs when a remote user leaves the channel.

You can know why the user leaves the channel through the `reason` parameter.

Parameters

  userId | The ID of the user who leaves the channel.
  reason | The reason why the remote user leaves the channel: USER_OFFLINE_REASON_TYPE.

## ◆ onTransportStats()

virtual void onTransportStats | ( | const RtcStats & | stats | ) |
| pure virtual

Reports the transport statistics of the connection.

The SDK triggers this callback once every two seconds when the connection state is `CONNECTION_STATE_CONNECTED`.

Parameters

  stats | The pointer to RtcStats.

## ◆ onChangeRoleSuccess()

virtual void onChangeRoleSuccess | ( | CLIENT_ROLE_TYPE | oldRole,
|  | CLIENT_ROLE_TYPE | newRole,
|  | const ClientRoleOptions & | newRoleOptions
| ) |  |
| inline virtual

Occurs when the role of the local user changes.

Parameters

  oldRole | The previous role of the local user: CLIENT_ROLE_TYPE.
  newRole | The current role of the local user: CLIENT_ROLE_TYPE.
  newRoleOptions | The client role options of the current role of the local user: ClientRoleOptions.

## ◆ onChangeRoleFailure()

virtual void onChangeRoleFailure | ( | CLIENT_ROLE_CHANGE_FAILED_REASON | reason,
|  | CLIENT_ROLE_TYPE | currentRole
| ) |  |
| inline virtual

Occurs when the local user fails to change the user role.

## ◆ onLicenseValidationFailure()

virtual void onLicenseValidationFailure | ( | LICENSE_ERROR_TYPE | error | ) |
| inline virtual

Occurs when connection license verification fails

You can know the reason accordding to error code

Parameters

  error | verify fail reason

## ◆ onUserNetworkQuality()

virtual void onUserNetworkQuality | ( | user_id_t | userId,
|  | QUALITY_TYPE | txQuality,
|  | QUALITY_TYPE | rxQuality
| ) |  |
| inline virtual

Reports the network quality of each user.

The SDK triggers this callback once every two seconds to report the uplink and downlink network conditions of each user in the channel, including the local user.

Parameters

  userId | The ID of the user. If `userId` is empty, this callback reports the network quality of the local user.
  txQuality | The uplink network quality: QUALITY_TYPE.
  rxQuality | The downlink network quality: QUALITY_TYPE.

## ◆ onNetworkTypeChanged()

virtual void onNetworkTypeChanged | ( | NETWORK_TYPE | type | ) |
| inline virtual

Occurs when the network type is changed.

Parameters

  type | The current network type. See NETWORK_TYPE.

## ◆ onContentInspectResult()

virtual void onContentInspectResult | ( | media::CONTENT_INSPECT_RESULT | result | ) |
| inline virtual

Reports result of Content Inspect

## ◆ onSnapshotTaken()

virtual void onSnapshotTaken | ( | user_id_t | userId,
|  | const char * | filePath,
|  | int | width,
|  | int | height,
|  | int | errCode
| ) |  |
| inline virtual

snapshot taken callback

Occurs when takeSnapshot API result is obtained

Parameters

  channel | channel name
  uid | user id
  filePath | image is saveed file path
  width | image width
  height | image height
  errCode | 0 is ok negative is error

## ◆ onError()

virtual void onError | ( | ERROR_CODE_TYPE | error,
|  | const char * | msg
| ) |  |
| inline virtual

Reports the error code and error message.

Parameters

  error | The error code: ERROR_CODE_TYPE.
  msg | The error message.

## ◆ onChannelMediaRelayStateChanged()

virtual void onChannelMediaRelayStateChanged | ( | int | state,
|  | int | code
| ) |  |
| pure virtual

Occurs when the state of the channel media relay changes.

Parameters

  state | The state code: `RELAY_STATE_IDLE(0)`: The SDK is initializing. `RELAY_STATE_CONNECTING(1)`: The SDK tries to relay the media stream to the destination channel. `RELAY_STATE_RUNNING(2)`: The SDK successfully relays the media stream to the destination channel. `RELAY_STATE_FAILURE(3)`: A failure occurs. See the details in `code`.
  code | The error code: `RELAY_OK(0)`: The state is normal. `RELAY_ERROR_SERVER_ERROR_RESPONSE(1)`: An error occurs in the server response. `RELAY_ERROR_SERVER_NO_RESPONSE(2)`: No server response. You can call the leaveChannel method to leave the channel. `RELAY_ERROR_NO_RESOURCE_AVAILABLE(3)`: The SDK fails to access the service, probably due to limited resources of the server. `RELAY_ERROR_FAILED_JOIN_SRC(4)`: Fails to send the relay request. `RELAY_ERROR_FAILED_JOIN_DEST(5)`: Fails to accept the relay request. `RELAY_ERROR_FAILED_PACKET_RECEIVED_FROM_SRC(6)`: The server fails to receive the media stream. `RELAY_ERROR_FAILED_PACKET_SENT_TO_DEST(7)`: The server fails to send the media stream. `RELAY_ERROR_SERVER_CONNECTION_LOST(8)`: The SDK disconnects from the server due to poor network connections. You can call the leaveChannel method to leave the channel. `RELAY_ERROR_INTERNAL_ERROR(9)`: An internal error occurs in the server. `RELAY_ERROR_SRC_TOKEN_EXPIRED(10)`: The token of the source channel has expired. `RELAY_ERROR_DEST_TOKEN_EXPIRED(11)`: The token of the destination channel has expired.

## ◆ onLocalUserRegistered()

virtual void onLocalUserRegistered | ( | uid_t | uid,
|  | const char * | userAccount
| ) |  |
| inline virtual

Occurs when the local user successfully registers a user account by calling the joinChannelWithUserAccount method.This callback reports the user ID and user account of the local user.

Parameters

  uid | The ID of the local user.
  userAccount | The user account of the local user.

## ◆ onUserAccountUpdated()

virtual void onUserAccountUpdated | ( | uid_t | uid,
|  | const char * | userAccount
| ) |  |
| inline virtual

Technical Preview, please do not depend on this event.

## ◆ onStreamMessageError()

virtual void onStreamMessageError | ( | user_id_t | userId,
|  | int | streamId,
|  | int | code,
|  | int | missed,
|  | int | cached
| ) |  |
| inline virtual

Reports the error that occurs when receiving data stream messages.

Parameters

  userId | The ID of the user sending the data stream.
  streamId | the ID of the sent data stream, returned in the createDataStream method.
  code | The error code.
  missed | The number of lost messages.
  cached | The number of incoming cached messages when the data stream is interrupted.

## ◆ onEncryptionError()

virtual void onEncryptionError | ( | ENCRYPTION_ERROR_TYPE | errorType | ) |
| inline virtual

Reports the error type of encryption.

Parameters

  type | See ENCRYPTION_ERROR_TYPE.

## ◆ onUploadLogResult()

virtual void onUploadLogResult | ( | const char * | requestId,
|  | bool | success,
|  | UPLOAD_ERROR_REASON | reason
| ) |  |
| inline virtual

Reports the user log upload result

Parameters

  requestId | RequestId of the upload
  success | Is upload success
  reason | Reason of the upload, 0: OK, 1 Network Error, 2 Server Error.

## ◆ onSetRtmFlagResult()

virtual void onSetRtmFlagResult | ( | int | code | ) |
| inline virtual

Occurs when receive use rtm response.

Parameters

  code | The error code:

## ◆ onMultipathStats()

virtual void onMultipathStats | ( | const MultipathStats & | stats | ) |
| inline virtual

Parameters

  stats | The path stats.