房间管理
房间表示一个多人的视频会话,本部分介绍如何进行房间管理,获取房间信息以及用户信息,介绍如何使用踢人、mute 等常见功能。
加入房间
本地调用 joinRoomWithToken:
通过 token
加入房间。
- (void)joinRoomWithToken:(NSString *)token;
此处 token
需要 App 从 App Server 中获取,App Server 如何生成 token 此处可查阅RoomToken 的计算。
本地用户加入房间成功后,远端用户会收到该用户加入房间成功的回调。
- (void)RTCSession:(QNRTCSession *)session didJoinOfRemoteUserId:(NSString *)userId;
房间信息
连麦房间中的用户的列表(不包含自己)。
@property (nonatomic, strong, readonly) NSArray<NSString *> *userList;
连麦房间中已发布音/视频的用户的列表(不包含自己)。
@property (nonatomic, strong, readonly) NSArray<NSString *> *publishingUserList;
注意:连麦状态为 QNRoomStateConnected 才可获取 userList
以及 publishingUserList
踢人
调用 kickoutUser:
将用户 userId 踢出房间
- (void)kickoutUser:(NSString *)userId;
当本地调用踢人的功能,将用户 userId 踢出房间,远端用户(userId)会收到被踢出房间的回调
- (void)RTCSession:(QNRTCSession *)session didKickoutByUserId:(NSString *)userId;
Mute 音/视频
是否 Mute 视频,置为 YES 后,远端用户用户将无法看到你的画面
@property (nonatomic, assign, getter=isMuteVideo) BOOL muteVideo;
本地用户调用设置 muteVideo
,远端用户会收到该用户(userId)视频状态变更的回调
- (void)RTCSession:(QNRTCSession *)session didVideoMuted:(BOOL)muted byRemoteUserId:(NSString *)userId;
是否 Mute 音频,置为 YES 后,远端用户用户将无法听你到你的声音
@property (nonatomic, assign, getter=isMuteAudio) BOOL muteAudio;
本地用户调用设置 muteAudio
,远端用户会收到该用户(userId)音频状态变更的回调
- (void)RTCSession:(QNRTCSession *)session didAudioMuted:(BOOL)muted byRemoteUserId:(NSString *)userId;
离开房间
本地调用 leaveRoom
离开房间。
- (void)leaveRoom;
本地用户离开房间成功后,远端用户会收到该用户(userId)离开房间的回调。
- (void)RTCSession:(QNRTCSession *)session didLeaveOfRemoteUserId:(NSString *)userId;