human: 如何处理七牛云的实时音视频QNClientEventListener

gpt: [实时音视频](https://developer.qiniu.com/rtc) > API 文档 > Windows
>QNClientEventListener

#  QNClientEventListener

最近更新时间: 2022-03-24 00:16:25

[QNRTCClient](https://developer.qiniu.com/rtc/9407/qnclienteventlistener/9446/QNRTCClient)
事件回调接口

Index

Core Methods

  * OnConnectionStateChanged
  * OnUserJoined
  * OnUserLeft
  * OnUserReconnecting
  * OnUserReconnected
  * OnUserPublished
  * OnUserUnpublished
  * OnSubscribed
  * OnMessageReceived
  * OnMediaRelayStateChanged

Core Methods

OnConnectionStateChanged

  * virtual void OnConnectionStateChanged(QNConnectionState state, const QNConnectionDisconnectedInfo* info) = 0
  * 房间连接状态变化时通知

Parameters

    * state: [QNConnectionState](https://developer.qiniu.com/rtc/9407/qnclienteventlistener/9464/QNConnectionState)

连接状态

    * info: [QNConnectionDisconnectedInfo](https://developer.qiniu.com/rtc/9407/qnclienteventlistener/9408/QNConnectionDisconnectedInfo)

断开连接时状态信息

OnUserJoined

  * virtual void OnUserJoined(const std::string& remote_user_id, const std::string& user_data) = 0
  * 远端用户加入房间时通知

Parameters

    * remote_user_id: string 

远端用户 id

    * user_data: string 

远端用户自定义消息

OnUserLeft

  * virtual void OnUserLeft(const std::string& remote_user_id) = 0
  * 远端用户离开房间时通知

Parameters

    * remote_user_id: string 

远端用户 id

OnUserReconnecting

  * virtual void OnUserReconnecting(const std::string& remote_user_id) = 0
  * 远端用户重连时通知

Parameters

    * remote_user_id: string 

远端用户 id

OnUserReconnected

  * virtual void OnUserReconnected(const std::string& remote_user_id) = 0
  * 远端用户重连成功时通知

Parameters

    * remote_user_id: string 

远端用户 id

OnUserPublished

  * virtual void OnUserPublished(const std::string& remote_user_id, const RemoteTrackList& track_list) = 0
  * 远端用户发布新 track 时通知

Parameters

    * remote_user_id: string 

远端用户 id

    * track_list: std::list<shared_ptr<[QNRemoteTrack](https://developer.qiniu.com/rtc/9407/qnclienteventlistener/9440/QNRemoteTrack)>>

远端用户新发布的 tracks

OnUserUnpublished

  * virtual void OnUserUnpublished(const std::string& remote_user_id, const RemoteTrackList& track_list) = 0
  * 远端用户取消发布 track 时通知

Parameters

    * remote_user_id: string 

远端用户 id

    * track_list: std::list<shared_ptr<[QNRemoteTrack](https://developer.qiniu.com/rtc/9407/qnclienteventlistener/9440/QNRemoteTrack)>>

远端用户取消发布的 tracks

OnSubscribed

  * virtual void OnSubscribed(const std::string& remote_user_id,const RemoteAudioTrackList& remote_audio_track_list,const RemoteVideoTrackList& remote_video_track_list) = 0
  * 订阅 track 成功时通知

Parameters

    * remote_user_id: string 

订阅的 track 所属的远端用户

    * remote_audio_track_list: std::list<shared_ptr<[QNRemoteAudioTrack](https://developer.qiniu.com/rtc/9407/qnclienteventlistener/9438/QNRemoteAudioTrack)>>

订阅的音频 tracks

    * remote_video_track_list: std::list<shared_ptr<[QNRemoteVideoTrack](https://developer.qiniu.com/rtc/9407/qnclienteventlistener/9443/QNRemoteVideoTrack)>>

订阅的视频 tracks

OnMessageReceived

  * virtual void OnMessageReceived(const CustomMessageList& message) = 0
  * 接收收到新的自定义消息时通知

Parameters

    * message: std::list<[QNCustomMessage](https://developer.qiniu.com/rtc/9407/qnclienteventlistener/9411/QNCustomMessage)>

自定义消息列表

OnMediaRelayStateChanged

  * virtual void OnMediaRelayStateChanged(const std::string& relay_room, const QNMediaRelayState state) = 0
  * 跨发媒体转发状态变更，非主动调用触发，由目标房间状态变化引起此通知

目前仅当目标房间关闭时，会触发此通知

Parameters

    * relay_room: string 

发生状态变化的房间名

    * state: [QNMediaRelayState](https://developer.qiniu.com/rtc/9407/qnclienteventlistener/undefined)

新状态，当前仅可能为 QNMediaRelayState::kRoomClosed

以上内容是否对您有帮助？