Agora Server Gateway SDK C++ API Reference
Public Member Functions | List of all members
agora::rtc::IRtcConnectionObserver Class Referenceabstract

#include <NGIAgoraRtcConnection.h>

Public Member Functions

virtual ~IRtcConnectionObserver ()
 
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 onReconnected (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 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)
 
virtual void onChangeRoleFailure ()
 
virtual void onUserNetworkQuality (user_id_t userId, QUALITY_TYPE txQuality, QUALITY_TYPE rxQuality)
 
virtual void onNetworkTypeChanged (NETWORK_TYPE type)
 
virtual void onApiCallExecuted (int err, const char *api, const char *result)
 
virtual void onError (ERROR_CODE_TYPE error, const char *msg)
 
virtual void onChannelMediaRelayStateChanged (int state, int code)=0
 
virtual void onEncryptionError (ENCRYPTION_ERROR_TYPE errorType)
 

Detailed Description

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

Constructor & Destructor Documentation

◆ ~IRtcConnectionObserver()

virtual agora::rtc::IRtcConnectionObserver::~IRtcConnectionObserver ( )
inlinevirtual

Member Function Documentation

◆ onApiCallExecuted()

virtual void agora::rtc::IRtcConnectionObserver::onApiCallExecuted ( int  err,
const char *  api,
const char *  result 
)
inlinevirtual

Occurs when an API method is executed.

Parameters
errThe error code that the SDK reports when the method call fails. If the SDK reports 0, the method call succeeds.
apiThe API method that is executed.
resultThe result of the method call.

◆ onChangeRoleFailure()

virtual void agora::rtc::IRtcConnectionObserver::onChangeRoleFailure ( )
inlinevirtual

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

◆ onChangeRoleSuccess()

virtual void agora::rtc::IRtcConnectionObserver::onChangeRoleSuccess ( CLIENT_ROLE_TYPE  oldRole,
CLIENT_ROLE_TYPE  newRole 
)
inlinevirtual

Occurs when the role of the local user changes.

Parameters
oldRoleThe previous role of the local user: CLIENT_ROLE_TYPE.
newRoleThe current role of the local user: CLIENT_ROLE_TYPE.

◆ onChannelMediaRelayStateChanged()

virtual void agora::rtc::IRtcConnectionObserver::onChannelMediaRelayStateChanged ( int  state,
int  code 
)
pure virtual

Occurs when the state of the channel media relay changes.

Parameters
stateThe 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.
codeThe 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.

◆ onConnected()

virtual void agora::rtc::IRtcConnectionObserver::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
connectionInfoThe information of the connection. See TConnectionInfo.
reasonThe reason of the connection state change. See CONNECTION_CHANGED_REASON_TYPE.

◆ onConnecting()

virtual void agora::rtc::IRtcConnectionObserver::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
connectionInfoThe information of the connection. See TConnectionInfo.
reasonThe reason of the connection state change. See CONNECTION_CHANGED_REASON_TYPE.

◆ onConnectionFailure()

virtual void agora::rtc::IRtcConnectionObserver::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
connectionInfoThe connection information: TConnectionInfo.
reasonThe reason of the connection state change: CONNECTION_CHANGED_REASON_TYPE.

◆ onConnectionLost()

virtual void agora::rtc::IRtcConnectionObserver::onConnectionLost ( const TConnectionInfo connectionInfo)
pure virtual

Occurs when the SDK loses connection with the Agora channel.

Parameters
connectionInfoThe information of the connection. See TConnectionInfo.

◆ onDisconnected()

virtual void agora::rtc::IRtcConnectionObserver::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
connectionInfoThe information of the connection. See TConnectionInfo.
reasonThe reason of the connection state change. See CONNECTION_CHANGED_REASON_TYPE.

◆ onEncryptionError()

virtual void agora::rtc::IRtcConnectionObserver::onEncryptionError ( ENCRYPTION_ERROR_TYPE  errorType)
inlinevirtual

Reports the error type of encryption.

Parameters
errorTypeEncryption error type.

◆ onError()

virtual void agora::rtc::IRtcConnectionObserver::onError ( ERROR_CODE_TYPE  error,
const char *  msg 
)
inlinevirtual

Reports an error during SDK runtime.

This callback indicates that an error (concerning network or media) occurs during SDK runtime. In most cases, the SDK cannot fix the issue and resume running. The SDK requires the app to take action or informs the user about the issue.

Parameters
errorThe error code.
msgThe error description.

◆ onLastmileProbeResult()

virtual void agora::rtc::IRtcConnectionObserver::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
resultThe result of the last-mile network probe test: LastmileProbeResult.

◆ onLastmileQuality()

virtual void agora::rtc::IRtcConnectionObserver::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
qualityQuality of the last-mile network: QUALITY_TYPE.

◆ onNetworkTypeChanged()

virtual void agora::rtc::IRtcConnectionObserver::onNetworkTypeChanged ( NETWORK_TYPE  type)
inlinevirtual

Occurs when the network type is changed.

Parameters
typeThe current network type. See NETWORK_TYPE.

◆ onReconnected()

virtual void agora::rtc::IRtcConnectionObserver::onReconnected ( const TConnectionInfo connectionInfo,
CONNECTION_CHANGED_REASON_TYPE  reason 
)
pure virtual

◆ onReconnecting()

virtual void agora::rtc::IRtcConnectionObserver::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
connectionInfoThe information of the connection. See TConnectionInfo.
reasonThe reason of the connection state change. See CONNECTION_CHANGED_REASON_TYPE.

◆ onTokenPrivilegeDidExpire()

virtual void agora::rtc::IRtcConnectionObserver::onTokenPrivilegeDidExpire ( )
pure virtual

Occurs when the token has expired.

Upon receiving this callback, you must generate a new token on your server and connect to the RTC channel with the new token.

◆ onTokenPrivilegeWillExpire()

virtual void agora::rtc::IRtcConnectionObserver::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
tokenThe pointer to the token that expires in 30 seconds.

◆ onTransportStats()

virtual void agora::rtc::IRtcConnectionObserver::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
statsThe pointer to RtcStats.

◆ onUserJoined()

virtual void agora::rtc::IRtcConnectionObserver::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
userIdThe ID of the remote user who joins the channel.

◆ onUserLeft()

virtual void agora::rtc::IRtcConnectionObserver::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
userIdThe ID of the user who leaves the channel.
reasonThe reason why the remote user leaves the channel: USER_OFFLINE_REASON_TYPE.

◆ onUserNetworkQuality()

virtual void agora::rtc::IRtcConnectionObserver::onUserNetworkQuality ( user_id_t  userId,
QUALITY_TYPE  txQuality,
QUALITY_TYPE  rxQuality 
)
inlinevirtual

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
userIdThe ID of the user. If userId is empty, this callback reports the network quality of the local user.
txQualityThe uplink network quality: QUALITY_TYPE.
rxQualityThe downlink network quality: QUALITY_TYPE.

The documentation for this class was generated from the following file: