425 lines
15 KiB
Objective-C
Executable File
425 lines
15 KiB
Objective-C
Executable File
//
|
||
// RCMicRoomViewModel.h
|
||
// SealMic
|
||
//
|
||
// Created by lichenfeng on 2020/6/8.
|
||
// Copyright © 2020 rongcloud. All rights reserved.
|
||
//
|
||
|
||
#import <Foundation/Foundation.h>
|
||
#import "BJChatMsgModel.h"
|
||
#import "RCMicParticipantViewModel.h"
|
||
#import "RCMicUserVip.h"
|
||
#import <AgoraRtcKit/AgoraRtcEngineKit.h>
|
||
#import "BJAgoraRtmManager.h"
|
||
#import "TXMicIMService.h"
|
||
#import "RoomSongListModel.h"
|
||
#import <AgoraRtcKit/AgoraMusicContentCenter.h>
|
||
|
||
typedef NS_ENUM(NSInteger, RCMicMessageChangedType) {
|
||
RCMicMessageChangedTypeAdd = 0,
|
||
RCMicMessageChangedTypeDelete,
|
||
RCMicMessageChangedTypeReload,
|
||
};
|
||
NS_ASSUME_NONNULL_BEGIN
|
||
|
||
@interface RCMicRoomViewModel : NSObject
|
||
|
||
@property (nonatomic, strong) AgoraRtcEngineKit *agoraKit;
|
||
@property (nonatomic, strong) RCMicRoomInfo *roomInfo;
|
||
@property (nonatomic, assign) RCMicRoleType role;//当前用户角色
|
||
/** 用户VIP信息 */
|
||
@property(nonatomic, strong) RCMicUserVip *vipInfo;
|
||
|
||
@property (nonatomic, assign) BOOL useMicrophone;//当前是否开启麦克风
|
||
@property (nonatomic, assign) BOOL useSpeaker;//当前是否打开扬声器
|
||
@property (nonatomic, assign) BOOL debugDisplay;//当前是否展示调试信息
|
||
@property (nonatomic, copy) NSMutableArray<BJChatMsgModel *> *messageDataSource;//消息数据源
|
||
@property (nonatomic, copy) NSMutableArray<BJChatMsgModel *> *siliaoMsgArray;//私聊消息数据源
|
||
@property (nonatomic, copy) NSMutableArray<BJChatMsgModel *> *atMsgArray;//@频道数据源
|
||
@property (nonatomic, copy) NSMutableArray<BJChatMsgModel *> *systemMsgArray;//系统消息数据源
|
||
@property (nonatomic, copy) NSMutableDictionary<NSString *, RCMicParticipantViewModel *>*participantDataSource;//参会者(麦位)数据源
|
||
|
||
@property (nonatomic, assign) BOOL isRoomOwner; //自己是该房房主,不随麦位变化而变化
|
||
@property (nonatomic, assign) BOOL isRoomAdministrator; //自己是该房管理员,不随麦位变化而变化
|
||
|
||
//判断当前自己是不是主持人
|
||
@property (nonatomic, assign) BOOL isRoomHost;
|
||
|
||
#pragma mark - UI 更新相关
|
||
|
||
/// 新增的声网播放音乐状态的回调
|
||
@property (nonatomic, copy) void(^agoraMusicStateBlock)(AgoraAudioMixingStateType state);
|
||
/// 加入聊天室后 KV 同步完成的回调,此回调触发后就可以从聊天室 KV 中获取相关信息了
|
||
@property (nonatomic, copy) void(^kvSyncCompleted)(void);
|
||
|
||
/// 消息数据源变化回调,携带变化的类型及索引(需要在主线程操作,因为涉及到和 cell 增删的同步)
|
||
@property (nonatomic, copy) void(^messageChanged)(RCMicMessageChangedType type, NSArray *indexs);
|
||
|
||
/// 参会者(麦位)数据源变化回调,携带发生变化的麦位在聊天室 KV 中对应的 key
|
||
@property (nonatomic, copy) void(^participantChanged)(NSArray<NSString *> *keys);
|
||
/// 新增的只更新光圈的block
|
||
@property (nonatomic, copy) void(^guangquanChanged)(NSArray<NSString *> *keys);
|
||
/// 参会者(麦位)首次加载完毕
|
||
@property (nonatomic, copy) void(^participantFirstLoad)(BOOL isOK);
|
||
|
||
/// 当前用户身份变化后的回调(只有持麦情况变化时会触发,在麦位上的身份互换不会触发)
|
||
@property (nonatomic, copy) void(^didHoldOrGiveUpMic)(RCMicRoleType role);
|
||
|
||
/// RTC 统计出的延迟信息发生变化回调,携带变化后的延迟
|
||
@property (nonatomic, copy) void(^delayInfoChanged)(NSInteger delay);
|
||
|
||
/// Debug 相关数据变化回调(只有开启 debug 模块时才会回调)
|
||
@property (nonatomic, copy) void(^debugInfoChanged)(NSArray *array);
|
||
|
||
/// 房间在线人数发生变化回调,携带变化后的人数
|
||
@property (nonatomic, copy) void(^onlineCountChanged)(NSInteger onlineCount);
|
||
|
||
/// 排麦人员状态变化回调,只有当前有人排麦和没人排麦的区别,不携带具体人数
|
||
@property (nonatomic, copy) void(^waitingStateChanged)(BOOL waiting);
|
||
|
||
/// 收到礼物消息的回调,携带所收到的礼物消息
|
||
@property (nonatomic, copy) void(^receivedSvgaGift)(NSString *svgaUrl, NSDictionary *cpDict);
|
||
|
||
/// 收到礼物消息的回调,携带所收到的礼物消息
|
||
@property (nonatomic, copy) void(^receivedNormGift)(NSString *uid, NSString *imgUrl);
|
||
|
||
/// 麦位上的禁言状态变化回调,携带当前是否被主持人禁言
|
||
@property (nonatomic, copy) void(^microPhoneStateChanged)(BOOL enable);
|
||
|
||
/// 收到被转让用户响应的回调,携带对方的名字、Id、是否同意接管主持人
|
||
@property (nonatomic, copy) void(^hostTransferResponse)(NSString *name, NSString *userId, BOOL result);
|
||
|
||
/// 收到被接管用户响应的回调,携带对方名字、Id、是否同意主持人被接管
|
||
@property (nonatomic, copy) void(^takeOverHostResponse)(NSString *name, NSString *userId, BOOL result);
|
||
|
||
/// 上下麦过程中关键点 error 回调,携带麦位转换中 RTC 及 IM 层出现的错误描述
|
||
@property (nonatomic, copy) void(^showTipWithErrorInfo)(NSString *description);
|
||
|
||
/// 上下麦过程中关键点 error 回调,携带麦位转换中 RTC 及 IM 层出现的错误描述
|
||
@property (nonatomic, copy) void(^bj_kickRoomBlock)(void);
|
||
|
||
/// 管理员身份发生改变
|
||
@property (nonatomic, copy) void(^bj_adminChangeBlock)(void);
|
||
|
||
/// 麦上人员发送表情
|
||
@property (nonatomic, copy) void(^bj_emojiBlock)(NSDictionary *eInfo);
|
||
/// 酒吧厅麦上人员显示勾手指
|
||
@property (nonatomic, copy) void(^bj_JiubaGifBlock)(NSDictionary *eInfo);
|
||
@property (nonatomic, copy) void(^bj_JiubaGifArrListBlock)(NSDictionary *eInfo);
|
||
|
||
///房间名字修改
|
||
@property(nonatomic, copy) void (^bj_roomNameChangeBLock)(NSString *room_name);
|
||
|
||
///房间背景图修改
|
||
@property(nonatomic, copy) void (^bj_roomBGChangeBlock)(NSString *room_bg);
|
||
|
||
///收到PK的Socket消息
|
||
@property(nonatomic, copy) void (^bj_PKSocketBlock)(NSDictionary *dataDict);
|
||
|
||
///收到锁房的Socket消息
|
||
@property(nonatomic, copy) void (^bj_lockRoomBlock)(void);
|
||
|
||
//全服喇叭
|
||
@property (nonatomic, copy) void(^bj_receiveLaba)(NSDictionary *dataDict);
|
||
|
||
//播放cp进场特效
|
||
@property (nonatomic, copy) void(^bj_PlayInRoomCPTXBlock)(NSDictionary *cp_info);
|
||
//摩天轮每天发放礼物
|
||
@property (nonatomic, copy) void(^bj_MotianlunDayBlcok)(NSDictionary *info);
|
||
|
||
|
||
@property (nonatomic, strong, nullable) RCMicParticipantInfo *currentParticipantInfo;//记录当前用户所在的麦位情况,如果当前为观众则此字段为 nil
|
||
|
||
#pragma mark - 初始化及销毁
|
||
- (instancetype)initWithRoomInfo:(RCMicRoomInfo *)roomInfo role:(RCMicRoleType)role;
|
||
|
||
/// 销毁房间时调用,释放资源
|
||
- (void)descory;
|
||
|
||
#pragma mark - 房间相关
|
||
/**
|
||
* 加入房间(分两步,先加入 IM 聊天室,成功后加入 RTC 房间)
|
||
*
|
||
* @param successBlock 成功回调
|
||
* @param imErrorBlock 加入 im 聊天室失败回调
|
||
* @param rtcErrorBlock 加入 rtc 房间失败回调
|
||
*/
|
||
- (void)joinMicRoom:(void(^)(void))successBlock
|
||
imError:(void(^)(void))imErrorBlock
|
||
rtcError:(void(^)(void))rtcErrorBlock;
|
||
|
||
/**
|
||
* 退出房间(退出当前页面时必须调用,否则会影响下次加入房间后相关功能的使用)
|
||
*/
|
||
- (void)quitMicRoom:(void(^)(void))successBlock error:(void(^)(void))errorBlock;
|
||
|
||
/**
|
||
* 发布或订阅音频流(需要加入房间成功后才能发布或订阅成功)
|
||
*/
|
||
- (void)publishOrSubscribeAudioStream:(void(^)(void))successBlock error:(void(^)(void))errorBlock;
|
||
|
||
|
||
#pragma mark - 消息模块 只显示
|
||
|
||
/// 显示当前房间的欢迎信息 不发送
|
||
- (void)bj_showRoomWelcome;
|
||
|
||
- (void)bj_showOwnerNotice;
|
||
|
||
/// 显示管理员清空消息
|
||
- (void)bj_showAdminClearMsg;
|
||
|
||
/// 发送游戏消息
|
||
- (void)bj_sendSudGameMsg:(NSString *)inputStr;
|
||
|
||
#pragma mark - 消息模块 发送
|
||
|
||
|
||
/// 发送管理员变动的消息
|
||
/// @param targetUid uid
|
||
/// @param isAddAdmin admin status
|
||
- (void)bj_sendAdminChangeMessageTo:(NSString *)targetUid isAdmin:(BOOL)isAddAdmin;
|
||
|
||
- (void)bj_sendHostChangeMessageTo:(NSString *)targetUid isAdmin:(BOOL)isAddAdmin;
|
||
|
||
/// 发送踢出房间的私聊消息
|
||
/// @param targetUid 被踢id
|
||
- (void)bj_sendKickRoomMessageTo:(NSString *)targetUid;
|
||
|
||
|
||
//禁言,禁麦,上下麦等操作
|
||
/// 发送踢出房间的私聊消息
|
||
/// @param targetUid 被踢id
|
||
- (void)bj_sendOperationRoomMessageTo:(NSString *)targetUid type:(BJIMMsgType)type;
|
||
|
||
/// 往聊天室发送我来了
|
||
- (void)bj_sendMyCommingWithVipInfo:(NSDictionary *)vipInfo;
|
||
|
||
/// 聊天室输入框
|
||
/// @param inputStr 输入内容
|
||
- (void)bj_sendInputString:(NSString *)inputStr siliao_id:(NSString *)siliao_id;
|
||
|
||
/// 管理员清空消息
|
||
- (void)bj_sendAdminClearMsg;
|
||
|
||
//房间设置,修改之后,
|
||
//发送房间公告,房间背景图url和房间名称给房间所有人
|
||
- (void)bj_sendRoomSettingMsg:(NSDictionary *)dict;
|
||
|
||
/// 发送表情
|
||
- (void)bj_sendEmojiMsg:(NSDictionary *)dict;
|
||
|
||
///发送表情
|
||
- (void)bj_sendPetMsg:(NSString *)svgaUrl cpInfo:(NSDictionary *)cpInfo;
|
||
|
||
/// 发送桌球猜猜乐信息
|
||
- (void)bj_sendZhuoqiuMsg:(NSArray *)dataArray type:(NSInteger)type;
|
||
|
||
#pragma mark - 麦位模块
|
||
/**
|
||
获取所有当前在麦位上的用户信息 userId
|
||
*/
|
||
- (NSArray *)currentParticipantUserIds;
|
||
|
||
/**
|
||
根据uid查询当前用户是否在麦位上,如果在返回麦位信息model
|
||
*/
|
||
- (RCMicParticipantViewModel *)getUserMicmsgWithUid:(NSString *)uid;
|
||
|
||
/**
|
||
* 加载所有麦位信息
|
||
*/
|
||
- (void)bj_loadAllParticipantViewModel:(void(^)(BOOL isOk))successBlock;
|
||
|
||
/**
|
||
* 将麦位在聊天室中对应的 key 转换为麦位索引
|
||
*/
|
||
- (NSInteger)transformEntryKeyToPosition:(NSString *)key;
|
||
|
||
/**
|
||
* 主动上麦
|
||
*/
|
||
- (void)bj_upParticipantWithMicId:(NSString *)mId finish:(void(^)(BOOL isOk))successBlock;
|
||
|
||
/**
|
||
* 当前用户下麦
|
||
*/
|
||
- (void)bj_downParticipant:(void(^)(BOOL isOK))successBlock;
|
||
|
||
#pragma mark - 锁麦相关
|
||
|
||
/**
|
||
* 对麦位进行解锁或加锁
|
||
*/
|
||
- (void)bj_lockPositionWithmicid:(NSString *)micId lock:(BOOL)isLock;
|
||
|
||
#pragma mark - 主持人相关
|
||
|
||
/**
|
||
* 强制用户上麦
|
||
*/
|
||
- (void)bj_inviteParticipant:(NSString *)userId error:(void (^)(BOOL isOk))finishBlock;
|
||
|
||
/**
|
||
* 抱人上麦
|
||
*/
|
||
- (void)bj_forceMicUpWithParticipant:(NSString *)userId micid:(NSString *)micId;
|
||
|
||
/**
|
||
* 将用户下麦
|
||
*/
|
||
- (void)bj_forceMicDownWithParticipant:(NSString *)userId;
|
||
|
||
/**
|
||
* 禁止语音说话
|
||
*/
|
||
- (void)bj_lockVoiceWithParticipant:(NSString *)userId;
|
||
|
||
/**
|
||
* 允许语音说话
|
||
*/
|
||
- (void)bj_unlockVoiceWithParticipant:(NSString *)userId;
|
||
|
||
/**
|
||
* 禁止打字说话
|
||
*/
|
||
- (void)bj_lockMsgWithParticipant:(NSString *)userId success:(void (^)(BOOL isOK))successBlock;
|
||
|
||
/**
|
||
* 允许打字说话
|
||
*/
|
||
- (void)bj_unlockMsgWithParticipant:(NSString *)userId;
|
||
|
||
/**
|
||
* 将用户踢出房间
|
||
*/
|
||
- (void)bj_kickUserOutRoom:(NSString *)userId success:(void (^)(void))successBlock error:(void (^)(RCMicHTTPCode))errorBlock;
|
||
|
||
/**
|
||
* 锁座位
|
||
*/
|
||
- (void)bj_lockSeatWithUid:(NSString *)userId position:(NSInteger)position success:(void (^)(BOOL isOK))successBlock;
|
||
|
||
/**
|
||
* 清空用户魅力值
|
||
*/
|
||
- (void)bj_clearCharmValueWithUid:(NSString *)userId success:(void (^)(BOOL isOK))successBlock;
|
||
|
||
/**
|
||
* 设置参会者(麦位)状态(设置自己麦位的状态时传 -1)
|
||
*/
|
||
- (void)changeParticipantState:(RCMicParticipantState)state
|
||
position:(NSInteger)position
|
||
success:(void(^)(void))successBlock
|
||
error:(void(^)(RCMicHTTPCode errorCode))errorBlock;
|
||
|
||
#pragma mark - 非主持人相关
|
||
/**
|
||
* 主持人上麦
|
||
*/
|
||
- (void)bj_upHostMic;
|
||
|
||
/// 主持人下麦
|
||
- (void)bj_downHostMic;
|
||
|
||
|
||
|
||
#pragma mark - oth
|
||
- (BOOL)uidIsRoomOwner:(NSString *)uid;
|
||
|
||
#pragma mark ------ KTV相关 ------
|
||
@property (nonatomic, strong) AgoraMusicContentCenter *ktvAmcc;
|
||
@property (nonatomic, strong) id<AgoraMusicPlayerProtocol> ktvPlayer;
|
||
|
||
@property(nonatomic, assign) BOOL isErfan;
|
||
@property(nonatomic, assign) NSInteger renshengVolume;//采集音量,取值范围为 [0,400],默认100
|
||
|
||
@property (nonatomic, strong) NSArray<RoomSongListModel *> *yidianSongArray;
|
||
@property (nonatomic, strong, nullable) RoomSongListModel *mineSongModel;
|
||
|
||
@property(nonatomic, assign) NSInteger playPosition;//播放进度
|
||
|
||
//当前唱歌或签约用户ID
|
||
@property (nonatomic, copy) NSString *songCurrentUid;
|
||
//当前阶段
|
||
@property (nonatomic, assign) NSInteger songCurrentStatus;
|
||
|
||
@property (nonatomic, copy) void(^ktv_UpdateYidianBlock)(NSArray *arr, BOOL showTiaoyin);
|
||
@property (nonatomic, copy) void(^ktv_SvgaStateBlock)(NSInteger is_play, NSInteger sex);
|
||
@property (nonatomic, copy) void(^ktv_UpdateCharmBlock)(NSString *charm, NSString *nickname);
|
||
@property (nonatomic, copy) void(^ktv_applyUpMicBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^ktv_loadLyricBlock)(NSString *lyricUrl, BOOL isQingchang);
|
||
@property (nonatomic, copy) void(^ktv_UpdatePlayBtnStatusBlock)(BOOL isPlay);
|
||
@property (nonatomic, copy) void(^ktv_updateStatusBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^ktv_zhizuorenTipsBlock)(NSDictionary *dict);
|
||
//交友厅的
|
||
@property (nonatomic, copy) void(^jiao_updateStageBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^jiao_chooseRelationBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^jiao_pendantGiftBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^simi_enterOrLeaveBlock)(BOOL enter);
|
||
@property (nonatomic, copy) void(^simi_updateTimeBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^simi_updateZhenxinBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^simi_updateGuangquanBlock)(NSString *uid);
|
||
//新人厅的
|
||
@property (nonatomic, copy) void(^xr_receiveInviteBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^xr_updateStatusBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^xr_updateRankBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^xr_qianyueResultBlock)(NSDictionary *dict);
|
||
//拍卖厅的
|
||
@property (nonatomic, copy) void(^pm_updateStatusBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^pm_paimaiResultBlock)(NSDictionary *dict);
|
||
//相亲厅
|
||
@property (nonatomic, copy) void(^xiangqin_updateStageBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^xiangqin_agreeJoinHechang)(void);
|
||
|
||
//酒吧相亲厅的
|
||
@property (nonatomic, copy) void(^xq_receiveInviteBlock)(NSDictionary *dict);
|
||
@property (nonatomic, copy) void(^xq_receiveGoSimiRoomBlock)(NSDictionary *dict);
|
||
|
||
/// 收到所有礼物消息,显示托盘
|
||
@property (nonatomic, copy) void(^receivedGiftTuopan)(NSDictionary *dict);
|
||
/// 盲盒巡乐会收到所有礼物消息,显示托盘
|
||
@property (nonatomic, copy) void(^blindReceivedGiftTuopan)(NSDictionary *dict, BOOL fromSelf);
|
||
///房间关闭或改变类型
|
||
@property(nonatomic, copy) void (^bj_receiveCloseRoomBlock)(NSDictionary *dict);
|
||
|
||
@property (nonatomic, copy) void(^bj_sudGameStart)(void);
|
||
@property (nonatomic, copy) void(^bj_sudGameEnd)(void);
|
||
@property(nonatomic, copy) void (^bj_RoomOwnerCloseAccountBlock)(void);
|
||
|
||
- (void)bj_requestSimiTouziData;
|
||
|
||
- (void)ktv_DestoryKtvPlayer;
|
||
|
||
- (void)ktv_SelfChangeSong;
|
||
|
||
-(void)ktv_OriginalSingSetting:(BOOL)isOriginal;
|
||
|
||
-(void)ktv_StartSing:(BOOL)isStart;
|
||
|
||
-(BOOL)ktv_GetErfan;
|
||
|
||
-(void)ktv_SetErfan:(BOOL)isErfan;
|
||
|
||
-(float)ktv_GetRenshengVolume;
|
||
|
||
-(void)ktv_SetRenshengVolume:(float)ratio;
|
||
|
||
-(float)ktv_GetBanzouVolume;
|
||
|
||
-(void)ktv_SetBanzouVolume:(float)ratio;
|
||
|
||
- (void)ktv_UpdateSelfSong;
|
||
|
||
- (void)bj_sendCPTXWithCPInfo:(NSDictionary *)cpInfo;
|
||
|
||
@property (nonatomic, assign) BOOL gameBanMic;//禁止推流
|
||
@property (nonatomic, assign) BOOL gameBanSpeaker;//禁止拉流
|
||
|
||
@property (nonatomic, assign) BOOL isHechang;
|
||
|
||
@end
|
||
|
||
NS_ASSUME_NONNULL_END
|