StageView 逻辑调整:兼容最小化进房或者房间模式切换
This commit is contained in:
@@ -70,13 +70,23 @@ typedef enum : NSUInteger {
|
||||
- (id)copy NS_UNAVAILABLE;
|
||||
- (id)mutableCopy NS_UNAVAILABLE;
|
||||
|
||||
/**
|
||||
* 加入频道(房间)
|
||||
/** 加入频道(房间)。
|
||||
|
||||
**Note:**
|
||||
|
||||
- 重复进房会直接 return YES。
|
||||
|
||||
@return - 进房结果。
|
||||
*/
|
||||
- (BOOL)enterRoom:(NSString *)roomUid;
|
||||
|
||||
/**
|
||||
* 加入频道(房间),TRTC 进房需要动态签名。
|
||||
/** 加入频道(房间),TRTC 进房需要动态签名。
|
||||
|
||||
**Note:**
|
||||
|
||||
- 重复进房会直接 return YES。
|
||||
|
||||
@return - 进房结果。
|
||||
*/
|
||||
- (BOOL)enterRoom:(NSString *)roomUid trtcSign:(NSString *)sign;
|
||||
|
||||
|
@@ -16,6 +16,11 @@
|
||||
@property (nonatomic, strong) id<RtcInterface> engine;
|
||||
@property (nonatomic, weak) id<RtcDelegate> engineDelegate;
|
||||
@property (nonatomic, assign) RtcEngineType engineType;
|
||||
/**
|
||||
* 当前 Rtc 所在的房间 roomUid 。
|
||||
*/
|
||||
@property(nonatomic, strong) NSString * enterdRoomUid;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RtcManager
|
||||
@@ -47,16 +52,24 @@
|
||||
}
|
||||
|
||||
- (BOOL)enterRoom:(NSString *)roomUid {
|
||||
if (self.enterdRoomUid && [self.enterdRoomUid isEqualToString:roomUid]) {
|
||||
return YES;
|
||||
}
|
||||
return [self.engine joinChannel:roomUid completion:^{
|
||||
[self muteRemote:NO];
|
||||
[self muteLocal:NO];
|
||||
self.enterdRoomUid = roomUid;
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)enterRoom:(NSString *)roomUid trtcSign:(nonnull NSString *)sign {
|
||||
if (self.enterdRoomUid && [self.enterdRoomUid isEqualToString:roomUid]) {
|
||||
return YES;
|
||||
}
|
||||
return [self.engine joinChannel:roomUid sign:sign completion:^{
|
||||
[self muteRemote:NO];
|
||||
[self muteLocal:NO];
|
||||
self.enterdRoomUid = roomUid;
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -79,6 +92,7 @@
|
||||
[self.engine exitChannel:^{
|
||||
[self muteRemote:NO];
|
||||
[self muteLocal:NO];
|
||||
self.enterdRoomUid = nil;
|
||||
}];
|
||||
}
|
||||
|
||||
@@ -109,6 +123,7 @@
|
||||
[_engine exitChannel:nil];
|
||||
[_engine destory];
|
||||
_engine = nil;
|
||||
_enterdRoomUid = nil;
|
||||
}
|
||||
_engineType = type;
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
#import <ReactiveObjC/ReactiveObjC.h>
|
||||
///Tool
|
||||
// Tools
|
||||
#import "RtcManager.h"
|
||||
#import "RtcDelegate.h"
|
||||
#import "TTPopup.h"
|
||||
@@ -19,7 +19,7 @@
|
||||
#import "Api+Room.h"
|
||||
#import "AccountInfoStorage.h"
|
||||
#import "XPRoomMiniManager.h"
|
||||
///Model
|
||||
// Models
|
||||
#import "RoomInfoModel.h"
|
||||
#import "UserInfoModel.h"
|
||||
#import "MicroStateModel.h"
|
||||
@@ -27,11 +27,10 @@
|
||||
#import "AttachmentModel.h"
|
||||
#import "GiftReceiveInfoModel.h"
|
||||
#import "GiftValueInfoModel.h"
|
||||
///View
|
||||
// Views
|
||||
#import "NetImageView.h"
|
||||
#import "XPUserCardViewController.h"
|
||||
|
||||
|
||||
@interface StageView()<RtcDelegate>
|
||||
|
||||
/** 云信麦序的 position 和本类 index 的关系。
|
||||
@@ -48,6 +47,7 @@
|
||||
@property (nonatomic, strong) NSMutableDictionary<NSString *, MicroQueueModel *> *micQueue;
|
||||
|
||||
@property (nonatomic, weak) id<RoomHostDelegate> hostDelegate;
|
||||
|
||||
/**
|
||||
* 是否正在上麦。
|
||||
* 防止快速点击连续上麦。
|
||||
@@ -78,45 +78,56 @@
|
||||
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(self.hightForStageView);
|
||||
}];
|
||||
|
||||
[self microQueueUpdated];
|
||||
|
||||
if (_hostDelegate.getRoomInfo) {
|
||||
[self initRtc];
|
||||
[self initNIMMicroQueues];
|
||||
} else {
|
||||
[self microQueueUpdated];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)initRtcRoom {
|
||||
#pragma mark - init functions
|
||||
/**
|
||||
* 既然是 initXXX,就不要随意调用或者添加逻辑。
|
||||
* 目前 init 要么在 [self initWithDelegate] ,要么在 [self onRoomEntered] 里面延迟初始化。因为初始化依赖房间信息。
|
||||
*/
|
||||
- (void)initRtc {
|
||||
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
|
||||
if ([XPRoomMiniManager shareManager].getRoomInfo.uid != roomInfo.uid) {
|
||||
// 1. 加入语音房间。
|
||||
RtcEngineType type;
|
||||
if ([roomInfo.audioSdkType isEqualToString:@"wujie"]) {
|
||||
type = RtcEngineType_WJ;
|
||||
} else if ([roomInfo.audioSdkType isEqualToString:@"zego"]) {
|
||||
type = RtcEngineType_Zego;
|
||||
} else if ([roomInfo.audioSdkType isEqualToString:@"trtc"]) {
|
||||
type = RtcEngineType_TRTC;
|
||||
} else {
|
||||
type = RtcEngineType_Agora;
|
||||
}
|
||||
[RtcManager initEngineWithType:type delegate:self];
|
||||
switch (type) {
|
||||
/**
|
||||
* 🐴 Agora
|
||||
* 🐴 Zego
|
||||
* 🦄️ TRTC
|
||||
* TRTC,就你 🦄️ 不一样?
|
||||
*/
|
||||
case RtcEngineType_TRTC:
|
||||
[[RtcManager instance] enterRoom:[NSString stringWithFormat:@"%ld", (long)roomInfo.roomId] trtcSign:roomInfo.trtcSig];
|
||||
break;
|
||||
|
||||
default:
|
||||
[[RtcManager instance] enterRoom:[NSString stringWithFormat:@"%ld", (long)roomInfo.roomId]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 获取麦位的状态,并初始化 self.micQueue 。
|
||||
// 加入语音房间。
|
||||
RtcEngineType type;
|
||||
if ([roomInfo.audioSdkType isEqualToString:@"wujie"]) {
|
||||
type = RtcEngineType_WJ;
|
||||
} else if ([roomInfo.audioSdkType isEqualToString:@"zego"]) {
|
||||
type = RtcEngineType_Zego;
|
||||
} else if ([roomInfo.audioSdkType isEqualToString:@"trtc"]) {
|
||||
type = RtcEngineType_TRTC;
|
||||
} else {
|
||||
type = RtcEngineType_Agora;
|
||||
}
|
||||
[RtcManager initEngineWithType:type delegate:self];
|
||||
switch (type) {
|
||||
/**
|
||||
* 🐴 Agora
|
||||
* 🐴 Zego
|
||||
* 🦄️ TRTC
|
||||
* TRTC,就你 🦄️ 不一样?
|
||||
*/
|
||||
case RtcEngineType_TRTC:
|
||||
[[RtcManager instance] enterRoom:[NSString stringWithFormat:@"%ld", (long)roomInfo.roomId] trtcSign:roomInfo.trtcSig];
|
||||
break;
|
||||
|
||||
default:
|
||||
[[RtcManager instance] enterRoom:[NSString stringWithFormat:@"%ld", (long)roomInfo.roomId]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)initNIMMicroQueues {
|
||||
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
|
||||
// 获取麦位的状态,并初始化 self.micQueue 。
|
||||
[[NIMSDK sharedSDK].chatroomManager fetchChatroomInfo:[NSString stringWithFormat:@"%ld", (long)roomInfo.roomId] completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom) {
|
||||
if (error) {
|
||||
return;
|
||||
@@ -131,11 +142,10 @@
|
||||
[self microQueueUpdated];
|
||||
}];
|
||||
|
||||
// 3. 获取麦位的用户,并初始化 self.micQueue 。
|
||||
// 获取麦位的用户,并初始化 self.micQueue 。
|
||||
[[NIMSDK sharedSDK].chatroomManager fetchChatroomQueue:[NSString stringWithFormat:@"%ld", (long)roomInfo.roomId] completion:^(NSError * _Nullable error, NSArray<NSDictionary<NSString *,NSString *> *> * _Nullable info) {
|
||||
if (error) {
|
||||
return;
|
||||
}
|
||||
if (error) return;
|
||||
|
||||
for (NSDictionary *item in info) {
|
||||
UserInfoModel *userInfo = [UserInfoModel modelWithJSON:item.allValues.firstObject];
|
||||
NSString *position = item.allKeys.firstObject;
|
||||
@@ -143,18 +153,24 @@
|
||||
sequence.userInfo = userInfo;
|
||||
}
|
||||
[self microQueueUpdated];
|
||||
|
||||
[Api roomMicroGiftValue:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200) {
|
||||
[self giftValueUpdate:data.data];
|
||||
}
|
||||
} roomUid:[NSString stringWithFormat:@"%ld", roomInfo.uid] uid:[AccountInfoStorage instance].getUid];
|
||||
// 最小化进房 如果当前用户在坑位上的话
|
||||
[self.hostDelegate onMicroQueueUpdate:self.micQueue];
|
||||
[self.hostDelegate onMicroQueueUpdate:self.micQueue];
|
||||
|
||||
// 拿到麦序后初始化礼物值
|
||||
[self initGiftValue];
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - microQueueUpdated
|
||||
- (void)initGiftValue{
|
||||
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
|
||||
// 获取礼物值
|
||||
[Api roomMicroGiftValue:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200) {
|
||||
[self giftValueUpdate:data.data];
|
||||
}
|
||||
} roomUid:[NSString stringWithFormat:@"%ld", roomInfo.uid] uid:[AccountInfoStorage instance].getUid];
|
||||
}
|
||||
|
||||
#pragma mark - update views as data changed
|
||||
/** 麦位状态或者卖上用户发生变化后,通过该方法刷新麦位的界面状态。
|
||||
* 且会根据当前用户和麦位状态等,决定音频推拉流。
|
||||
*
|
||||
@@ -168,21 +184,12 @@
|
||||
MicroQueueModel * model = [self.micQueue objectForKey:[self indexToPosition:i]];
|
||||
|
||||
UIView<MicroViewProtocol> * view = [self findMicroViewByIndex:i];
|
||||
[view configRoomInfo:roomInfo];
|
||||
[view configMicQueue:self.micQueue];
|
||||
[view configRoomInfo:roomInfo];
|
||||
[view configMicQueue:self.micQueue];
|
||||
[view configMicroView:model];
|
||||
[view showLeaveMode:i == 0 && leaveMode];
|
||||
if (roomInfo.leaveMode) {
|
||||
if (i == 0) {
|
||||
if (!roomInfo.showGiftValue) [view resetGiftValue];
|
||||
} else {
|
||||
if ((model.userInfo == nil || !roomInfo.showGiftValue)) [view resetGiftValue];
|
||||
}
|
||||
} else {
|
||||
if ((model.userInfo == nil || !roomInfo.showGiftValue)) [view resetGiftValue];
|
||||
}
|
||||
|
||||
[view showGiftValueMode:roomInfo.showGiftValue];
|
||||
if (model.userInfo == nil || !roomInfo.showGiftValue) [view resetGiftValue];
|
||||
[view showGiftValueMode:roomInfo.showGiftValue];
|
||||
if (self.hostDelegate.getUserInfo.uid && model.userInfo.uid == self.hostDelegate.getUserInfo.uid) {
|
||||
selfNeedBroadcast = model.microState.micState == MicroMicStateType_Open;
|
||||
}
|
||||
@@ -229,7 +236,8 @@
|
||||
|
||||
#pragma mark - RoomGuestDelegate
|
||||
- (void)onRoomEntered {
|
||||
[self initRtcRoom];
|
||||
[self initRtc];
|
||||
[self initNIMMicroQueues];
|
||||
}
|
||||
|
||||
- (NSMutableDictionary<NSString *,MicroQueueModel *> *)getMicroQueue {
|
||||
@@ -241,8 +249,8 @@
|
||||
}
|
||||
|
||||
- (void)handleNIMNotificationMessage:(NIMMessage *)message {
|
||||
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
|
||||
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
|
||||
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
|
||||
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
|
||||
BOOL microQueueChanged = NO;
|
||||
switch (content.eventType) {
|
||||
case NIMChatroomEventTypeInfoUpdated: // 麦序状态更新
|
||||
@@ -285,29 +293,29 @@
|
||||
if (changeType == 1) { // 上麦
|
||||
MicroQueueModel *sequence = [self.micQueue objectForKey:position];
|
||||
sequence.userInfo = userInfo;
|
||||
if (self.hostDelegate.getRoomInfo.showGiftValue && userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
|
||||
RoomInfoModel * roomInfo =self.hostDelegate.getRoomInfo;
|
||||
NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
|
||||
NSString * uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
[Api roomGiftValueUpMic:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200) {
|
||||
NIMMessage * message = [[NIMMessage alloc] init];
|
||||
AttachmentModel * attachMent = [[AttachmentModel alloc] init];
|
||||
attachMent.first = CustomMessageType_Room_GiftValue;
|
||||
attachMent.second = Custom_Message_Sub_Room_GiftValue_Sync;
|
||||
attachMent.data = data.data;
|
||||
NIMCustomObject *object = [[NIMCustomObject alloc] init];
|
||||
object.attachment = attachMent;
|
||||
message.messageObject = object;
|
||||
//构造会话
|
||||
NSString * sessionId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
|
||||
NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom];
|
||||
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
|
||||
}
|
||||
} roomUid:roomUid micUid:uid position:position uid:uid];
|
||||
}
|
||||
if (self.hostDelegate.getRoomInfo.showGiftValue && userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
|
||||
RoomInfoModel * roomInfo =self.hostDelegate.getRoomInfo;
|
||||
NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
|
||||
NSString * uid = [NSString stringWithFormat:@"%ld", userInfo.uid];
|
||||
[Api roomGiftValueUpMic:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200) {
|
||||
NIMMessage * message = [[NIMMessage alloc] init];
|
||||
AttachmentModel * attachMent = [[AttachmentModel alloc] init];
|
||||
attachMent.first = CustomMessageType_Room_GiftValue;
|
||||
attachMent.second = Custom_Message_Sub_Room_GiftValue_Sync;
|
||||
attachMent.data = data.data;
|
||||
NIMCustomObject *object = [[NIMCustomObject alloc] init];
|
||||
object.attachment = attachMent;
|
||||
message.messageObject = object;
|
||||
//构造会话
|
||||
NSString * sessionId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
|
||||
NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom];
|
||||
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
|
||||
}
|
||||
} roomUid:roomUid micUid:uid position:position uid:uid];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
microQueueChanged = YES;
|
||||
}
|
||||
break;
|
||||
@@ -335,51 +343,51 @@
|
||||
}
|
||||
|
||||
- (void)handleNIMCustomMessage:(NIMMessage *)message {
|
||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
||||
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
||||
if(attachment.first == CustomMessageType_Queue && attachment.second == Custom_Message_Sub_Queue_Invite) {
|
||||
NSDictionary *dic = attachment.data;
|
||||
|
||||
NSString *uid = dic[@"uid"];
|
||||
if (uid.integerValue == self.hostDelegate.getUserInfo.uid) {
|
||||
NSNumber *micPosition = dic[@"micPosition"];
|
||||
NSString *position = micPosition.stringValue;
|
||||
|
||||
MicroQueueModel *micro = [self.micQueue objectForKey:position];
|
||||
if (!micro || micro.userInfo) return; // 当前麦位有人,什么都不做。
|
||||
|
||||
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
|
||||
NSString* roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
|
||||
UserInfoModel* userInfo = self.hostDelegate.getUserInfo;
|
||||
|
||||
NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init];
|
||||
request.key = position;
|
||||
request.value = [[self configUpdateChatRoomQueueExt:userInfo] toJSONString];
|
||||
request.roomId = roomId;
|
||||
request.transient = YES;
|
||||
|
||||
[[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) {
|
||||
if (error) return;
|
||||
[RtcManager instance].localMuted = YES;
|
||||
TTAlertConfig *config = [[TTAlertConfig alloc] init];
|
||||
config.title = @"房主或管理员拉你上麦";
|
||||
config.message = @"你已被房主或管理员拉上麦,但并未开启麦克风。如需要说话,请打开麦克风。";
|
||||
[TTPopup alertWithConfig:config confirmHandler:^{
|
||||
|
||||
} cancelHandler:^{
|
||||
|
||||
}];
|
||||
}];
|
||||
}
|
||||
} else if(attachment.first == CustomMessageType_Room_GiftValue && attachment.second == Custom_Message_Sub_Room_GiftValue_Sync) {
|
||||
[self giftValueUpdate:attachment.data];
|
||||
} else if(attachment.first == CustomMessageType_Gift && (attachment.second == Custom_Message_Sub_Gift_Send || attachment.second == Custom_Message_Sub_Gift_LuckySend || attachment.second == Custom_Message_Sub_Gift_ChannelNotify)) {
|
||||
[self giftValueUpdate:attachment.data];
|
||||
}else if(attachment.first == CustomMessageType_AllMicroSend && (attachment.second == Custom_Message_Sub_AllMicroSend || attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend)) {
|
||||
[self giftValueUpdate:attachment.data];
|
||||
}
|
||||
}
|
||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
||||
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
||||
if(attachment.first == CustomMessageType_Queue && attachment.second == Custom_Message_Sub_Queue_Invite) {
|
||||
NSDictionary *dic = attachment.data;
|
||||
|
||||
NSString *uid = dic[@"uid"];
|
||||
if (uid.integerValue == self.hostDelegate.getUserInfo.uid) {
|
||||
NSNumber *micPosition = dic[@"micPosition"];
|
||||
NSString *position = micPosition.stringValue;
|
||||
|
||||
MicroQueueModel *micro = [self.micQueue objectForKey:position];
|
||||
if (!micro || micro.userInfo) return; // 当前麦位有人,什么都不做。
|
||||
|
||||
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
|
||||
NSString* roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
|
||||
UserInfoModel* userInfo = self.hostDelegate.getUserInfo;
|
||||
|
||||
NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init];
|
||||
request.key = position;
|
||||
request.value = [[self userInfoToQueueExt:userInfo] toJSONString];
|
||||
request.roomId = roomId;
|
||||
request.transient = YES;
|
||||
|
||||
[[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) {
|
||||
if (error) return;
|
||||
[RtcManager instance].localMuted = YES;
|
||||
TTAlertConfig *config = [[TTAlertConfig alloc] init];
|
||||
config.title = @"房主或管理员拉你上麦";
|
||||
config.message = @"你已被房主或管理员拉上麦,但并未开启麦克风。如需要说话,请打开麦克风。";
|
||||
[TTPopup alertWithConfig:config confirmHandler:^{
|
||||
|
||||
} cancelHandler:^{
|
||||
|
||||
}];
|
||||
}];
|
||||
}
|
||||
} else if(attachment.first == CustomMessageType_Room_GiftValue && attachment.second == Custom_Message_Sub_Room_GiftValue_Sync) {
|
||||
[self giftValueUpdate:attachment.data];
|
||||
} else if(attachment.first == CustomMessageType_Gift && (attachment.second == Custom_Message_Sub_Gift_Send || attachment.second == Custom_Message_Sub_Gift_LuckySend || attachment.second == Custom_Message_Sub_Gift_ChannelNotify)) {
|
||||
[self giftValueUpdate:attachment.data];
|
||||
}else if(attachment.first == CustomMessageType_AllMicroSend && (attachment.second == Custom_Message_Sub_AllMicroSend || attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend)) {
|
||||
[self giftValueUpdate:attachment.data];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - RtcDelegate - 讲话的波纹回调
|
||||
@@ -410,7 +418,7 @@
|
||||
void(^nimUpQueue)(NSString*, BOOL) = ^ (NSString* up, BOOL isFromDownMic){
|
||||
NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init];
|
||||
request.key = up;
|
||||
request.value = [[self configUpdateChatRoomQueueExt:userInfo] toJSONString];
|
||||
request.value = [[self userInfoToQueueExt:userInfo] toJSONString];
|
||||
request.roomId = roomId;
|
||||
request.transient = YES;
|
||||
[[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) {
|
||||
@@ -450,12 +458,12 @@
|
||||
}
|
||||
}];
|
||||
|
||||
NSString * lockTitle;
|
||||
if (roomInfo.roomModeType == RoomModeType_Open_Micro_Mode) {
|
||||
lockTitle = micModel.microState.posState == MicroPosStateType_Free ? @"切换为排麦" : @"切换为自由麦";
|
||||
} else {
|
||||
lockTitle = micModel.microState.posState == MicroPosStateType_Free ? @"锁麦" : @"解锁";
|
||||
}
|
||||
NSString * lockTitle;
|
||||
if (roomInfo.roomModeType == RoomModeType_Open_Micro_Mode) {
|
||||
lockTitle = micModel.microState.posState == MicroPosStateType_Free ? @"切换为排麦" : @"切换为自由麦";
|
||||
} else {
|
||||
lockTitle = micModel.microState.posState == MicroPosStateType_Free ? @"锁麦" : @"解锁";
|
||||
}
|
||||
TTActionSheetConfig *lockMic = [TTActionSheetConfig normalTitle:lockTitle clickAction:^{
|
||||
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
|
||||
NSString * state = micModel.microState.posState == MicroPosStateType_Free ? @"1" : @"0";
|
||||
@@ -503,12 +511,6 @@
|
||||
XPUserCardViewController * userCardVC = [[XPUserCardViewController alloc] initWithUser:model];
|
||||
[self.hostDelegate.getCurrentNav presentViewController:userCardVC animated:YES completion:nil];
|
||||
} else {
|
||||
|
||||
if (roomInfo.roomModeType == RoomModeType_Open_Blind) {
|
||||
[XCHUDTool showErrorWithMessage:@"当前上麦需要主持操作,无法自主上麦"];
|
||||
return;
|
||||
}
|
||||
|
||||
if (roomInfo.leaveMode && roomInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
|
||||
[XCHUDTool showErrorWithMessage:@"请先关闭离开模式"];
|
||||
return;
|
||||
@@ -564,14 +566,30 @@
|
||||
return -1;
|
||||
}
|
||||
|
||||
#pragma mark - private utils function
|
||||
/**
|
||||
* 网易云信的麦序转成坑位的 index
|
||||
* 麦位更新扩展字段。
|
||||
*/
|
||||
- (NSDictionary *)userInfoToQueueExt:(UserInfoModel *)userInfo {
|
||||
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
|
||||
[dic setValue:@(userInfo.gender) forKey:@"gender"];
|
||||
[dic setValue:userInfo.avatar forKey:@"avatar"];
|
||||
[dic setValue:@(userInfo.uid) forKey:@"uid"];
|
||||
[dic setValue:userInfo.nick forKey:@"nick"];
|
||||
NSString * headWearUrl = userInfo.headwearEffect.length > 0 ? userInfo.headwearEffect : userInfo.headwearPic;
|
||||
if (headWearUrl.length > 0) {
|
||||
[dic setValue:headWearUrl forKey:@"headWearUrl"];
|
||||
}
|
||||
return dic;
|
||||
}
|
||||
/**
|
||||
* 网易云信的麦序转成坑位的 index。
|
||||
*/
|
||||
- (NSInteger)positionToIndex:(NSString*)position {
|
||||
return position.intValue + 1;
|
||||
}
|
||||
/**
|
||||
* 坑位的 index 转成网易云信的麦序
|
||||
* 坑位的 index 转成网易云信的麦序。
|
||||
*/
|
||||
- (NSString *)indexToPosition:(NSInteger)index {
|
||||
return [NSString stringWithFormat:@"%ld", (long)(index - 1)];
|
||||
|
Reference in New Issue
Block a user