优化 AdvertiseModel 和 XPRoomViewController,移除不必要的注释,新增上麦请求弹窗定时器,增强消息处理逻辑,提升代码可维护性和用户体验。同时,更新本地化字符串,支持新的上麦邀请功能。
This commit is contained in:
@@ -18,7 +18,7 @@ typedef NS_ENUM(NSInteger, SplashInfoSkipType) {
|
||||
SplashInfoSkipTypeWeb_Custom = 6,
|
||||
};
|
||||
|
||||
@interface AdvertiseFillModel : PIBaseModel//<NSCoding>
|
||||
@interface AdvertiseFillModel : PIBaseModel
|
||||
|
||||
@property(nonatomic, copy) NSString *loverNick;
|
||||
@property(nonatomic, copy) NSString *loverErbanNo;
|
||||
@@ -32,7 +32,7 @@ typedef NS_ENUM(NSInteger, SplashInfoSkipType) {
|
||||
|
||||
@end
|
||||
|
||||
@interface AdvertiseModel : PIBaseModel//<NSCopying>
|
||||
@interface AdvertiseModel : PIBaseModel
|
||||
@property (nonatomic, strong) NSString *link;
|
||||
@property (nonatomic, assign) SplashInfoSkipType type;// 1跳app页面,2跳聊天室,3跳h5页面,
|
||||
@property (nonatomic, copy) NSString *pict;
|
||||
|
@@ -81,7 +81,7 @@
|
||||
#import "BannerScheduler.h"
|
||||
|
||||
static const CGFloat kTipViewStayDuration = 3.0;
|
||||
static const CGFloat kTipViewMoveDuration = 0.5;
|
||||
//static const CGFloat kTipViewMoveDuration = 0.5;
|
||||
|
||||
@interface RoomAnimationView () <
|
||||
PAGViewListener,
|
||||
|
@@ -135,9 +135,6 @@
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)configDefaultData {
|
||||
#if DEBUG
|
||||
self.userInfo.isManager = NO;
|
||||
#endif
|
||||
if (self.userInfo.isManager) {
|
||||
[self.applyButton setTitle:YMLocalizedString(@"XPArrangeMicViewController1") forState:UIControlStateNormal];
|
||||
} else {
|
||||
|
@@ -326,9 +326,7 @@
|
||||
}
|
||||
|
||||
- (void)handleUpMicAction:(NIMChatroomMember *)member {
|
||||
|
||||
// TODO: 处理接收逻辑
|
||||
|
||||
|
||||
NSError *error = nil;
|
||||
NSData *data = [member.roomExt dataUsingEncoding:NSUTF8StringEncoding];
|
||||
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data
|
||||
@@ -350,12 +348,20 @@
|
||||
attachment.first = ClientMessage_Type;
|
||||
attachment.second = ClientMessage_UpMic_Ask;
|
||||
NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
|
||||
[data setObject:[AccountInfoStorage instance].getUid
|
||||
[data setObject:@([[AccountInfoStorage instance].getUid integerValue])
|
||||
forKey:@"uid"];
|
||||
[data setObject:member.userId forKey:@"targetUid"];
|
||||
[data setObject:self.position forKey:@"position"];
|
||||
[data setObject:@(self.roomType) forKey:@"roomType"];
|
||||
[data setObject:@([[NSDate date] timeIntervalSince1970])
|
||||
[data setObject:@(member.userId.integerValue)
|
||||
forKey:@"targetUid"];
|
||||
[data setObject:@(self.position.integerValue)
|
||||
forKey:@"position"];
|
||||
[data setObject:@(self.roomType)
|
||||
forKey:@"roomType"];
|
||||
[data setObject:member.roomNickname
|
||||
forKey:@"targetNick"];
|
||||
[data setObject:@(self.roomUid.integerValue)
|
||||
forKey:@"roomUid"];
|
||||
int64_t millis = (int64_t)([[NSDate date] timeIntervalSince1970] * 1000);
|
||||
[data setObject:@(millis)
|
||||
forKey:@"sendTime"];
|
||||
attachment.data = data;
|
||||
|
||||
@@ -365,25 +371,20 @@
|
||||
object.attachment = attachment;
|
||||
message.messageObject = object;
|
||||
|
||||
// UserInfoModel *userInfo = [self.delegate getUserInfo];
|
||||
// XPMessageRemoteExtModel *extModel = [[XPMessageRemoteExtModel alloc] init];
|
||||
// extModel.androidBubbleUrl = userInfo.androidBubbleUrl;
|
||||
// extModel.iosBubbleUrl = userInfo.iosBubbleUrl;
|
||||
// extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel;
|
||||
// extModel.platformRole = userInfo.platformRole;
|
||||
// NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:[NSString stringWithFormat:@"%ld", userInfo.uid]];
|
||||
// message.remoteExt = member.;
|
||||
NIMSessionType sessionType = NIMSessionTypeChatroom;
|
||||
//构造会话
|
||||
NIMSession *session = [NIMSession session:sessionID type:sessionType];
|
||||
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session completion:^(NSError * _Nullable error) {
|
||||
BOOL onMain = [NSThread isMainThread];
|
||||
if (error) {
|
||||
NSLog(@"[Combo effect][Send] ❌ 发送失败 | sessionId=%@ | code=%ld | desc=%@ | main=%@ | ts=%.3f",
|
||||
NSLog(@"[Send] ❌ 发送失败 | sessionId=%@ | code=%ld | desc=%@ | main=%@ | ts=%.3f",
|
||||
sessionID, (long)error.code, error.localizedDescription, onMain ? @"YES" : @"NO", [[NSDate date] timeIntervalSince1970]);
|
||||
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"20.20.62_text_8")];
|
||||
} else {
|
||||
NSLog(@"[Combo effect][Send] ✅ 发送成功 | sessionId=%@ | main=%@ | ts=%.3f",
|
||||
NSLog(@"[Send] ✅ 发送成功 | sessionId=%@ | main=%@ | ts=%.3f",
|
||||
sessionID, onMain ? @"YES" : @"NO", [[NSDate date] timeIntervalSince1970]);
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"20.20.62_text_3")];
|
||||
}
|
||||
}];
|
||||
} else {
|
||||
|
@@ -1346,22 +1346,68 @@
|
||||
}
|
||||
|
||||
- (void)buildUpMicMessage:(XPUserCardItemModel *)item {
|
||||
NSString * roomId = [NSString stringWithFormat:@"%ld", self.cardInfo.roomInfo.roomId];
|
||||
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
|
||||
[dic setValue:@(item.position.integerValue) forKey:@"micPosition"];
|
||||
[dic setValue:@(self.userInfoModel.uid) forKey:@"uid"];
|
||||
AttachmentModel *attachement = [[AttachmentModel alloc]init];
|
||||
attachement.first = CustomMessageType_Queue;
|
||||
attachement.second = Custom_Message_Sub_Queue_Invite;
|
||||
attachement.data = dic;
|
||||
|
||||
AttachmentModel *attachment = [[AttachmentModel alloc] init];
|
||||
attachment.first = ClientMessage_Type;
|
||||
attachment.second = ClientMessage_UpMic_Ask;
|
||||
NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
|
||||
[data setObject:@([[AccountInfoStorage instance].getUid integerValue])
|
||||
forKey:@"uid"];
|
||||
[data setObject:@(self.userInfoModel.uid)
|
||||
forKey:@"targetUid"];
|
||||
[data setObject:@(item.position.integerValue)
|
||||
forKey:@"position"];
|
||||
[data setObject:@(self.cardInfo.roomInfo.type)
|
||||
forKey:@"roomType"];
|
||||
[data setObject:self.userInfoModel.nick
|
||||
forKey:@"targetNick"];
|
||||
[data setObject:@(self.cardInfo.roomInfo.uid)
|
||||
forKey:@"roomUid"];
|
||||
int64_t millis = (int64_t)([[NSDate date] timeIntervalSince1970] * 1000);
|
||||
[data setObject:@(millis)
|
||||
forKey:@"sendTime"];
|
||||
attachment.data = data;
|
||||
|
||||
NSString *sessionID = [NSString stringWithFormat:@"%ld", self.cardInfo.roomInfo.roomId];
|
||||
NIMMessage *message = [[NIMMessage alloc]init];
|
||||
NIMCustomObject *object = [[NIMCustomObject alloc] init];
|
||||
object.attachment = attachement;
|
||||
object.attachment = attachment;
|
||||
message.messageObject = object;
|
||||
|
||||
NIMSessionType sessionType = NIMSessionTypeChatroom;
|
||||
//构造会话
|
||||
NIMSession *session = [NIMSession session:roomId type:NIMSessionTypeChatroom];
|
||||
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
|
||||
NIMSession *session = [NIMSession session:sessionID type:sessionType];
|
||||
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session completion:^(NSError * _Nullable error) {
|
||||
BOOL onMain = [NSThread isMainThread];
|
||||
if (error) {
|
||||
NSLog(@"[Send] ❌ 发送失败 | sessionId=%@ | code=%ld | desc=%@ | main=%@ | ts=%.3f",
|
||||
sessionID, (long)error.code, error.localizedDescription, onMain ? @"YES" : @"NO", [[NSDate date] timeIntervalSince1970]);
|
||||
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"20.20.62_text_8")];
|
||||
} else {
|
||||
NSLog(@"[Send] ✅ 发送成功 | sessionId=%@ | main=%@ | ts=%.3f",
|
||||
sessionID, onMain ? @"YES" : @"NO", [[NSDate date] timeIntervalSince1970]);
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"20.20.62_text_3")];
|
||||
}
|
||||
}];
|
||||
|
||||
// NSString * roomId = [NSString stringWithFormat:@"%ld", self.cardInfo.roomInfo.roomId];
|
||||
// NSMutableDictionary * dic = [NSMutableDictionary dictionary];
|
||||
// [dic setValue:@(item.position.integerValue) forKey:@"micPosition"];
|
||||
// [dic setValue:@(self.userInfoModel.uid) forKey:@"uid"];
|
||||
// AttachmentModel *attachement = [[AttachmentModel alloc]init];
|
||||
// attachement.first = CustomMessageType_Queue;
|
||||
// attachement.second = Custom_Message_Sub_Queue_Invite;
|
||||
// attachement.data = dic;
|
||||
//
|
||||
// NIMMessage *message = [[NIMMessage alloc]init];
|
||||
// NIMCustomObject *object = [[NIMCustomObject alloc] init];
|
||||
// object.attachment = attachement;
|
||||
// message.messageObject = object;
|
||||
// //构造会话
|
||||
// NIMSession *session = [NIMSession session:roomId type:NIMSessionTypeChatroom];
|
||||
// [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
|
||||
|
||||
[self dismissViewControllerAnimated:YES completion:^{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"PopAfterUserCardAction" object:nil];
|
||||
}];
|
||||
|
@@ -192,6 +192,9 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
|
||||
@property(nonatomic,strong) UIButton *exitGameButton;
|
||||
|
||||
/// 上麦请求弹窗定时器,用于10秒后自动移除弹窗
|
||||
@property(nonatomic,strong) NSTimer *upMicAskTimer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XPRoomViewController
|
||||
@@ -317,6 +320,12 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
_animationView = nil;
|
||||
}
|
||||
|
||||
// 清理上麦请求弹窗定时器
|
||||
if (self.upMicAskTimer) {
|
||||
[self.upMicAskTimer invalidate];
|
||||
self.upMicAskTimer = nil;
|
||||
}
|
||||
|
||||
NSLog(@"🔄 XPRoomViewController: 销毁完成");
|
||||
}
|
||||
|
||||
@@ -1881,10 +1890,6 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
|
||||
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
|
||||
// 入口排查日志:批次大小、线程和时间戳
|
||||
NSLog(@"[Combo effect][Recv] 📥 onRecvMessages | count=%lu | main=%@ | ts=%.3f",
|
||||
(unsigned long)messages.count,
|
||||
[NSThread isMainThread] ? @"YES" : @"NO",
|
||||
[[NSDate date] timeIntervalSince1970]);
|
||||
for (NIMMessage * message in messages) {
|
||||
///房间内收到p2p的消息 比如升级消息
|
||||
if (message.session.sessionType == NIMSessionTypeP2P) {
|
||||
@@ -1906,261 +1911,324 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
|
||||
// 非房间内消息不处理(记录过滤原因)
|
||||
if (message.session.sessionType != NIMSessionTypeChatroom) {
|
||||
NSLog(@"[Combo effect][Recv] ⛔️ 过滤:非聊天室消息 | type=%ld | sid=%@",
|
||||
NSLog(@"[Recv] ⛔️ 过滤:非聊天室消息 | type=%ld | sid=%@",
|
||||
(long)message.session.sessionType, message.session.sessionId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (![message.session.sessionId isEqualToString:@(self.roomInfo.roomId).stringValue]) {
|
||||
NSLog(@"[Combo effect][Recv] ⛔️ 过滤:房间不匹配 | msg.sid=%@ | curRoomId=%@",
|
||||
NSLog(@"[Recv] ⛔️ 过滤:房间不匹配 | msg.sid=%@ | curRoomId=%@",
|
||||
message.session.sessionId, @(self.roomInfo.roomId).stringValue);
|
||||
continue;
|
||||
}
|
||||
|
||||
// NSLog(@" --- Message Raw Attach Content: %@, %@, %ld", @(message.senderClientType), message.rawAttachContent, (long)message.messageType);
|
||||
NSLog(@"[Recv] --- Message Raw Attach Content: %@, %@, %ld", @(message.senderClientType), message.rawAttachContent, (long)message.messageType);
|
||||
|
||||
if (message.messageType == NIMMessageTypeNotification) {
|
||||
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
|
||||
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
|
||||
|
||||
// NSLog(@" --- Message Content class: %@", [notiMsg.content class]);
|
||||
// if ([notiMsg.content isKindOfClass:[NIMUnsupportedNotificationContent class]]) {
|
||||
// NSLog(@"Fuck %@", message);
|
||||
// }
|
||||
|
||||
if (![notiMsg.content isKindOfClass:[NIMChatroomNotificationContent class]]) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSInteger onLineNumber = self.roomInfo.onlineNum;
|
||||
switch (content.eventType) {
|
||||
case NIMChatroomEventTypeInfoUpdated: // 麦序状态更新
|
||||
{
|
||||
NSDictionary *data = [content.notifyExt toJSONObject];
|
||||
int type = [data[@"type"] intValue];
|
||||
switch (type) {
|
||||
case 1: // 房间信息变化
|
||||
case 3: // 房间信息 & 麦位信息变化
|
||||
{
|
||||
NSMutableDictionary *lastRoomInfoDic = [NSMutableDictionary dictionaryWithDictionary:[self.roomInfo model2dictionary]];
|
||||
[lastRoomInfoDic addEntriesFromDictionary: ((NSString *)data[@"roomInfo"]).toJSONObject];
|
||||
RoomInfoModel *newRoomInfo = [RoomInfoModel modelWithJSON:lastRoomInfoDic];
|
||||
|
||||
if (newRoomInfo.type != RoomType_MiniGame) {
|
||||
newRoomInfo.mgId = 0;
|
||||
}
|
||||
newRoomInfo.hasAnimationEffect = self.hasAnimationEffect;
|
||||
if (newRoomInfo.roomModeType == RoomModeType_Open_Blind && self.roomInfo.roomModeType != RoomModeType_Open_Blind) {
|
||||
///普通房 切换为相亲房
|
||||
newRoomInfo.datingState = RoomDatingStateChangeType_Open;
|
||||
} else if(newRoomInfo.roomModeType != RoomModeType_Open_Blind && self.roomInfo.roomModeType == RoomModeType_Open_Blind) {
|
||||
///关闭了相亲房
|
||||
newRoomInfo.datingState = RoomDatingStateChangeType_Close;
|
||||
} else {
|
||||
newRoomInfo.datingState = RoomDatingStateChangeType_Normal;
|
||||
}
|
||||
//房间类型是否变更了(从个播->普通,个播->小游戏等)
|
||||
newRoomInfo.hadChangeRoomType = self.roomInfo.type != newRoomInfo.type;
|
||||
BOOL anchorToOther = newRoomInfo.type != RoomType_Anchor && self.roomInfo.type == RoomType_Anchor;//个播变其他房
|
||||
self.roomInfo = newRoomInfo;
|
||||
|
||||
[self.backContainerView onRoomUpdate];
|
||||
|
||||
self.quickMessageContainerView.titleArray = self.roomInfo.speakTemplate;
|
||||
if (self.roomInfo.type == RoomType_Anchor && self.roomInfo.hadChangeRoomType) {///从其他房变为个播房
|
||||
[self handleInitAnchorRoom];
|
||||
[self showAnchorScrollTipView];
|
||||
} else if (anchorToOther) {
|
||||
[self __removeAllViews];
|
||||
|
||||
[self.view addSubview:self.backContainerView];
|
||||
[self.view addSubview:self.stageView];
|
||||
[self.view addSubview:self.messageContainerView];
|
||||
[self.view addSubview:self.quickMessageContainerView];
|
||||
[self.view addSubview:self.menuContainerView];
|
||||
[self.view addSubview:self.sideMenu];
|
||||
[self.view addSubview:self.roomHeaderView];
|
||||
[self.view bringSubviewToFront:self.menuContainerView];
|
||||
[self.view addSubview:self.functionView];
|
||||
[self.view bringSubviewToFront:self.animationView];
|
||||
|
||||
[self initSubViewConstraints];
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
[self.stageView onRoomUpdate];
|
||||
[self.menuContainerView onRoomUpdate];
|
||||
[self.functionView onRoomUpdate];
|
||||
[self.sideMenu onRoomUpdate];
|
||||
[self.messageContainerView onRoomUpdate];
|
||||
[self.littleGameView onRoomUpdate];
|
||||
} else {
|
||||
if (self.roomInfo.type == RoomType_Anchor) {
|
||||
[self changeStageViewOnAnchorRoom];
|
||||
} else if (self.roomInfo.type == RoomType_20Mic) {
|
||||
[self __layoutTwentyMicStage];
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
[self.twentyMicStageView onRoomUpdate];
|
||||
} else if (self.roomInfo.type == RoomType_19Mic) {
|
||||
[self __layoutNineteenMicStage];
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
[self.nineteenMicStageView onRoomUpdate];
|
||||
} else if (self.roomInfo.type == RoomType_15Mic) {
|
||||
[self __layoutFifteenMicStage];
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
[self.fifteenMicStageView onRoomUpdate];
|
||||
} else if (self.roomInfo.type == RoomType_10Mic) {
|
||||
[self __layoutTenMicStage];
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
[self.tenMicStageView onRoomUpdate];
|
||||
} else {
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
}
|
||||
[self.stageView onRoomUpdate];
|
||||
[self.menuContainerView onRoomUpdate];
|
||||
[self.functionView onRoomUpdate];
|
||||
[self.sideMenu onRoomUpdate];
|
||||
|
||||
[self.messageContainerView onRoomUpdate];
|
||||
[self.littleGameView onRoomUpdate];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NIMChatroomEventTypeEnter:
|
||||
{
|
||||
if (content.source.userId.integerValue == [AccountInfoStorage instance].getUid.integerValue){
|
||||
[self.presenter getKickUserListWithRoomUid:@(self.roomInfo.uid).stringValue];
|
||||
}
|
||||
if (content.source.userId.integerValue != [AccountInfoStorage instance].getUid.integerValue && self.userInfo.platformRole != 1) {
|
||||
onLineNumber += 1;
|
||||
}else {
|
||||
///如果是自己的话 如果有坐骑的话
|
||||
[self userEnterRoomSuccess];
|
||||
///在活动页面 判断是否显示 相亲加入的按钮 所以需要等用户进房成功之后才能获取 房间角色
|
||||
[self.sideMenu onRoomUpdate];
|
||||
|
||||
[self.menuContainerView onRoomUpdate];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case NIMChatroomEventTypeAddBlack:
|
||||
case NIMChatroomEventTypeKicked:
|
||||
case NIMChatroomEventTypeExit:
|
||||
onLineNumber -= 1;
|
||||
break;
|
||||
case NIMChatroomEventTypeQueueChange: // 麦序上下麦
|
||||
{
|
||||
NSDictionary* data = (NSDictionary *)content.ext;
|
||||
UserInfoModel* userInfo = [UserInfoModel modelWithJSON:[data objectForKey:NIMChatroomEventInfoQueueChangeItemValueKey]];
|
||||
NSInteger changeType = [data[NIMChatroomEventInfoQueueChangeTypeKey] integerValue];
|
||||
if (changeType == 1 && userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
|
||||
[self cancelRoomArrangeMic];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NIMChatroomEventTypeAddManager: {
|
||||
NIMChatroomNotificationMember *targets = [content.targets firstObject];
|
||||
if (targets.userId.integerValue == self.userInfo.uid) {
|
||||
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"1.0.34_text_15")];
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case NIMChatroomEventTypeRemoveManager: {
|
||||
NIMChatroomNotificationMember *targets = [content.targets firstObject];
|
||||
if (targets.userId.integerValue == self.userInfo.uid) {
|
||||
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"1.0.34_text_16")];
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
self.roomInfo.onlineNum = onLineNumber;
|
||||
[self.functionView updateOnlineCount:[NSString stringWithFormat:@"%ld",onLineNumber] countList:@[] isUpdateCount:YES];
|
||||
[self.roomHeaderView onRoomUpdate];
|
||||
[self.stageView handleNIMNotificationMessage:message];
|
||||
[self.animationView handleNIMNotificationMessage:message];
|
||||
[self.messageContainerView handleNIMNotificationMessage:message];
|
||||
[self.sideMenu handleNIMNotificationMessage:message];
|
||||
[self.menuContainerView handleNIMNotificationMessage:message];
|
||||
[self.functionView handleNIMNotificationMessage:message];
|
||||
[self.littleGameView handleNIMNotificationMessage:message];
|
||||
if([self.stageView findMicroViewByUid:@(self.userInfo.uid).stringValue] != nil){
|
||||
[XPSkillCardPlayerManager shareInstance].isMineInMic = YES;
|
||||
}else{
|
||||
[XPSkillCardPlayerManager shareInstance].isMineInMic = NO;
|
||||
};
|
||||
[self handleNIMNotificationTypeMessage:message];
|
||||
} else if (message.messageType == NIMMessageTypeCustom) {
|
||||
// 自定义消息排查日志:first/second/size
|
||||
// 自定义消息排查日志:first/second/size3
|
||||
#if DEBUG
|
||||
if ([message.messageObject isKindOfClass:[NIMCustomObject class]]) {
|
||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||
if ([obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
||||
AttachmentModel *att = (AttachmentModel *)obj.attachment;
|
||||
NSData *payloadJSON = nil;
|
||||
@try { payloadJSON = [NSJSONSerialization dataWithJSONObject:att.data ?: @{} options:0 error:nil]; } @catch (__unused NSException *e) {}
|
||||
NSLog(@"[Combo effect][Recv] 🎯 自定义消息 | first=%ld second=%ld | payload=%lub | sid=%@ | ts=%.3f",
|
||||
NSLog(@"[Recv] 🎯 自定义消息 | first=%ld second=%ld | payload=%lub | sid=%@ | ts=%.3f",
|
||||
(long)att.first, (long)att.second, (unsigned long)payloadJSON.length,
|
||||
message.session.sessionId, [[NSDate date] timeIntervalSince1970]);
|
||||
}
|
||||
}
|
||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
||||
AttachmentModel * attachment = (AttachmentModel *)obj.attachment;
|
||||
[self.stageView handleNIMCustomMessage:message];
|
||||
[self.animationView handleNIMCustomMessage:message];
|
||||
[self.menuContainerView handleNIMCustomMessage:message];
|
||||
[self.sideMenu handleNIMCustomMessage:message];
|
||||
[self.functionView handleNIMCustomMessage:message];
|
||||
[self.littleGameView handleNIMCustomMessage:message];
|
||||
[self.messageContainerView handleNIMCustomMessage:message];
|
||||
#endif
|
||||
[self handleNimCustomTypeMessage:message];
|
||||
} else if(message.messageType == NIMMessageTypeText) {
|
||||
[self.messageContainerView handleNIMTextMessage:message];
|
||||
[self.littleGameView handleNIMTextMessage:message];
|
||||
} else if(message.messageType == NIMMessageTypeTip) {
|
||||
[self.messageContainerView handleNIMTextMessage:message];
|
||||
}else if(message.messageType == NIMMessageTypeImage){
|
||||
[self.messageContainerView handleNIMImageMessage:message];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (attachment.first == CustomMessageType_First_Recharge_Reward && attachment.second == Custom_Message_Sub_Room_First_Recharge_Reward) {
|
||||
self.userInfo.isFirstCharge = NO;
|
||||
[self.menuContainerView onRoomUpdate];
|
||||
[self.sideMenu onRoomUpdate];
|
||||
} else if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) {
|
||||
///兼容安卓和iOS 协议不同的问题
|
||||
NSDictionary * dic= attachment.data[@"roomInfo"];
|
||||
if (dic.allKeys.count <=0) {
|
||||
dic = attachment.data;
|
||||
- (void)handleNIMNotificationTypeMessage:(NIMMessage *)message {
|
||||
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
|
||||
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
|
||||
|
||||
if (![notiMsg.content isKindOfClass:[NIMChatroomNotificationContent class]]) {
|
||||
// content 可能为其他类型,不处理
|
||||
return;
|
||||
}
|
||||
|
||||
NSInteger onLineNumber = self.roomInfo.onlineNum;
|
||||
switch (content.eventType) {
|
||||
case NIMChatroomEventTypeInfoUpdated: // 麦序状态更新
|
||||
{
|
||||
NSDictionary *data = [content.notifyExt toJSONObject];
|
||||
[self handleSwitchRoomType:data];
|
||||
}
|
||||
break;
|
||||
case NIMChatroomEventTypeEnter:
|
||||
{
|
||||
if (content.source.userId.integerValue == [AccountInfoStorage instance].getUid.integerValue){
|
||||
[self.presenter getKickUserListWithRoomUid:@(self.roomInfo.uid).stringValue];
|
||||
}
|
||||
if (content.source.userId.integerValue != [AccountInfoStorage instance].getUid.integerValue && self.userInfo.platformRole != 1) {
|
||||
onLineNumber += 1;
|
||||
}else {
|
||||
///如果是自己的话 如果有坐骑的话
|
||||
[self userEnterRoomSuccess];
|
||||
///在活动页面 判断是否显示 相亲加入的按钮 所以需要等用户进房成功之后才能获取 房间角色
|
||||
[self.sideMenu onRoomUpdate];
|
||||
|
||||
[self.menuContainerView onRoomUpdate];
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case NIMChatroomEventTypeAddBlack:
|
||||
case NIMChatroomEventTypeKicked:
|
||||
case NIMChatroomEventTypeExit:
|
||||
onLineNumber -= 1;
|
||||
break;
|
||||
case NIMChatroomEventTypeQueueChange: // 麦序上下麦
|
||||
{
|
||||
NSDictionary* data = (NSDictionary *)content.ext;
|
||||
UserInfoModel* userInfo = [UserInfoModel modelWithJSON:[data objectForKey:NIMChatroomEventInfoQueueChangeItemValueKey]];
|
||||
NSInteger changeType = [data[NIMChatroomEventInfoQueueChangeTypeKey] integerValue];
|
||||
if (changeType == 1 && userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {
|
||||
[self cancelRoomArrangeMic];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NIMChatroomEventTypeAddManager: {
|
||||
NIMChatroomNotificationMember *targets = [content.targets firstObject];
|
||||
if (targets.userId.integerValue == self.userInfo.uid) {
|
||||
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"1.0.34_text_15")];
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case NIMChatroomEventTypeRemoveManager: {
|
||||
NIMChatroomNotificationMember *targets = [content.targets firstObject];
|
||||
if (targets.userId.integerValue == self.userInfo.uid) {
|
||||
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"1.0.34_text_16")];
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
self.roomInfo.onlineNum = onLineNumber;
|
||||
[self.functionView updateOnlineCount:[NSString stringWithFormat:@"%ld",onLineNumber] countList:@[] isUpdateCount:YES];
|
||||
[self.roomHeaderView onRoomUpdate];
|
||||
[self.stageView handleNIMNotificationMessage:message];
|
||||
[self.animationView handleNIMNotificationMessage:message];
|
||||
[self.messageContainerView handleNIMNotificationMessage:message];
|
||||
[self.sideMenu handleNIMNotificationMessage:message];
|
||||
[self.menuContainerView handleNIMNotificationMessage:message];
|
||||
[self.functionView handleNIMNotificationMessage:message];
|
||||
[self.littleGameView handleNIMNotificationMessage:message];
|
||||
if([self.stageView findMicroViewByUid:@(self.userInfo.uid).stringValue] != nil){
|
||||
[XPSkillCardPlayerManager shareInstance].isMineInMic = YES;
|
||||
}else{
|
||||
[XPSkillCardPlayerManager shareInstance].isMineInMic = NO;
|
||||
};
|
||||
}
|
||||
|
||||
- (void)handleSwitchRoomType:(NSDictionary *)data {
|
||||
int type = [data[@"type"] intValue];
|
||||
switch (type) {
|
||||
case 1: // 房间信息变化
|
||||
case 3: // 房间信息 & 麦位信息变化
|
||||
{
|
||||
NSMutableDictionary *lastRoomInfoDic = [NSMutableDictionary dictionaryWithDictionary:[self.roomInfo model2dictionary]];
|
||||
[lastRoomInfoDic addEntriesFromDictionary: ((NSString *)data[@"roomInfo"]).toJSONObject];
|
||||
RoomInfoModel *newRoomInfo = [RoomInfoModel modelWithJSON:lastRoomInfoDic];
|
||||
|
||||
if (newRoomInfo.type != RoomType_MiniGame) {
|
||||
newRoomInfo.mgId = 0;
|
||||
}
|
||||
newRoomInfo.hasAnimationEffect = self.hasAnimationEffect;
|
||||
if (newRoomInfo.roomModeType == RoomModeType_Open_Blind && self.roomInfo.roomModeType != RoomModeType_Open_Blind) {
|
||||
///普通房 切换为相亲房
|
||||
newRoomInfo.datingState = RoomDatingStateChangeType_Open;
|
||||
} else if(newRoomInfo.roomModeType != RoomModeType_Open_Blind && self.roomInfo.roomModeType == RoomModeType_Open_Blind) {
|
||||
///关闭了相亲房
|
||||
newRoomInfo.datingState = RoomDatingStateChangeType_Close;
|
||||
} else {
|
||||
newRoomInfo.datingState = RoomDatingStateChangeType_Normal;
|
||||
}
|
||||
//房间类型是否变更了(从个播->普通,个播->小游戏等)
|
||||
newRoomInfo.hadChangeRoomType = self.roomInfo.type != newRoomInfo.type;
|
||||
BOOL anchorToOther = newRoomInfo.type != RoomType_Anchor && self.roomInfo.type == RoomType_Anchor;//个播变其他房
|
||||
self.roomInfo = newRoomInfo;
|
||||
|
||||
[self.backContainerView onRoomUpdate];
|
||||
|
||||
self.quickMessageContainerView.titleArray = self.roomInfo.speakTemplate;
|
||||
if (self.roomInfo.type == RoomType_Anchor && self.roomInfo.hadChangeRoomType) {///从其他房变为个播房
|
||||
[self handleInitAnchorRoom];
|
||||
[self showAnchorScrollTipView];
|
||||
} else if (anchorToOther) {
|
||||
[self __removeAllViews];
|
||||
|
||||
[self.view addSubview:self.backContainerView];
|
||||
[self.view addSubview:self.stageView];
|
||||
[self.view addSubview:self.messageContainerView];
|
||||
[self.view addSubview:self.quickMessageContainerView];
|
||||
[self.view addSubview:self.menuContainerView];
|
||||
[self.view addSubview:self.sideMenu];
|
||||
[self.view addSubview:self.roomHeaderView];
|
||||
[self.view bringSubviewToFront:self.menuContainerView];
|
||||
[self.view addSubview:self.functionView];
|
||||
[self.view bringSubviewToFront:self.animationView];
|
||||
|
||||
[self initSubViewConstraints];
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
[self.stageView onRoomUpdate];
|
||||
[self.menuContainerView onRoomUpdate];
|
||||
[self.functionView onRoomUpdate];
|
||||
[self.sideMenu onRoomUpdate];
|
||||
[self.messageContainerView onRoomUpdate];
|
||||
[self.littleGameView onRoomUpdate];
|
||||
} else {
|
||||
if (self.roomInfo.type == RoomType_Anchor) {
|
||||
[self changeStageViewOnAnchorRoom];
|
||||
} else if (self.roomInfo.type == RoomType_20Mic) {
|
||||
[self __layoutTwentyMicStage];
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
[self.twentyMicStageView onRoomUpdate];
|
||||
} else if (self.roomInfo.type == RoomType_19Mic) {
|
||||
[self __layoutNineteenMicStage];
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
[self.nineteenMicStageView onRoomUpdate];
|
||||
} else if (self.roomInfo.type == RoomType_15Mic) {
|
||||
[self __layoutFifteenMicStage];
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
[self.fifteenMicStageView onRoomUpdate];
|
||||
} else if (self.roomInfo.type == RoomType_10Mic) {
|
||||
[self __layoutTenMicStage];
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
[self.tenMicStageView onRoomUpdate];
|
||||
} else {
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
}
|
||||
[self.stageView onRoomUpdate];
|
||||
[self.menuContainerView onRoomUpdate];
|
||||
[self.functionView onRoomUpdate];
|
||||
[self.sideMenu onRoomUpdate];
|
||||
|
||||
[self.messageContainerView onRoomUpdate];
|
||||
[self.littleGameView onRoomUpdate];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleNimCustomTypeMessage:(NIMMessage *)message {
|
||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
||||
AttachmentModel * attachment = (AttachmentModel *)obj.attachment;
|
||||
[self.stageView handleNIMCustomMessage:message];
|
||||
[self.animationView handleNIMCustomMessage:message];
|
||||
[self.menuContainerView handleNIMCustomMessage:message];
|
||||
[self.sideMenu handleNIMCustomMessage:message];
|
||||
[self.functionView handleNIMCustomMessage:message];
|
||||
[self.littleGameView handleNIMCustomMessage:message];
|
||||
[self.messageContainerView handleNIMCustomMessage:message];
|
||||
|
||||
switch (attachment.first) {
|
||||
case ClientMessage_Type:
|
||||
switch (attachment.second) {
|
||||
case ClientMessage_UpMic_Ask:
|
||||
[self handleUpMicAsk:attachment];
|
||||
break;
|
||||
case ClientMessage_UpMic_Agree:
|
||||
[self handleUpMicAgree:attachment];
|
||||
break;
|
||||
case ClientMessage_UpMic_Reject:
|
||||
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"20.20.62_text_4")];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CustomMessageType_First_Recharge_Reward:
|
||||
switch (attachment.second) {
|
||||
case Custom_Message_Sub_Room_First_Recharge_Reward:
|
||||
self.userInfo.isFirstCharge = NO;
|
||||
[self.menuContainerView onRoomUpdate];
|
||||
[self.sideMenu onRoomUpdate];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CustomMessageType_Update_RoomInfo:
|
||||
switch (attachment.second) {
|
||||
case Custom_Message_Sub_Update_RoomInfo_MessageState: {
|
||||
///兼容安卓和iOS 协议不同的问题
|
||||
NSDictionary * dic= attachment.data[@"roomInfo"];
|
||||
if (dic.allKeys.count <=0) {
|
||||
dic = attachment.data;
|
||||
}
|
||||
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic];
|
||||
self.roomInfo.isCloseScreen = roomInfo.isCloseScreen;
|
||||
|
||||
[self.menuContainerView onRoomUpdate];
|
||||
}
|
||||
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic];
|
||||
self.roomInfo.isCloseScreen = roomInfo.isCloseScreen;
|
||||
|
||||
[self.menuContainerView onRoomUpdate];
|
||||
|
||||
}else if(attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_AnimateEffect){
|
||||
break;
|
||||
|
||||
case Custom_Message_Sub_Update_RoomInfo_AnimateEffect: {
|
||||
NSDictionary * dic= attachment.data[@"roomInfo"];
|
||||
if (dic.allKeys.count <=0) {
|
||||
dic = attachment.data;
|
||||
}
|
||||
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic];
|
||||
self.roomInfo.hasAnimationEffect = roomInfo.hasAnimationEffect;
|
||||
[self.roomHeaderView onRoomUpdate];
|
||||
[self.roomHeaderView onRoomUpdate];
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if(attachment.first == CustomMessageType_Queue && attachment.second == Custom_Message_Sub_Queue_Invite) {
|
||||
NSDictionary *dic = attachment.data;
|
||||
NSString *uid = dic[@"uid"];
|
||||
if (uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) {
|
||||
[self cancelRoomArrangeMic];
|
||||
break;
|
||||
|
||||
case CustomMessageType_Queue:
|
||||
switch (attachment.second) {
|
||||
case Custom_Message_Sub_Queue_Invite: {
|
||||
NSDictionary *dic = attachment.data;
|
||||
NSString *uid = dic[@"uid"];
|
||||
if (uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) {
|
||||
[self cancelRoomArrangeMic];
|
||||
}
|
||||
}
|
||||
} else if(attachment.first == CustomMessageType_Hall_Super_Admin && attachment.second == Custom_Message_Sub_Hall_Super_Admin_Kick_Manager_Out_Room) {
|
||||
XPKickUserModel * userInfo = [XPKickUserModel modelWithJSON:attachment.data];
|
||||
if (userInfo.targetUid == [AccountInfoStorage instance].getUid.integerValue) {
|
||||
[self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]];
|
||||
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
||||
[self cancelRoomArrangeMic];
|
||||
[[RtcManager instance] exitRoom];
|
||||
[self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]];
|
||||
[self.littleGameView handleSelfInExitEvent];
|
||||
[self.littleGameView destroyMG];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CustomMessageType_Hall_Super_Admin:
|
||||
switch (attachment.second) {
|
||||
case Custom_Message_Sub_Hall_Super_Admin_Kick_Manager_Out_Room: {
|
||||
XPKickUserModel * userInfo = [XPKickUserModel modelWithJSON:attachment.data];
|
||||
if (userInfo.targetUid == [AccountInfoStorage instance].getUid.integerValue) {
|
||||
[self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]];
|
||||
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
||||
[self cancelRoomArrangeMic];
|
||||
[[RtcManager instance] exitRoom];
|
||||
[self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]];
|
||||
[self.littleGameView handleSelfInExitEvent];
|
||||
[self.littleGameView destroyMG];
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
} else if (attachment.first == CustomMessageType_RedPacket) {
|
||||
if (attachment.second == Custom_Message_Sub_RoomDiamandRedPacket) {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CustomMessageType_RedPacket:
|
||||
switch (attachment.second) {
|
||||
case Custom_Message_Sub_RoomDiamandRedPacket: {
|
||||
XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
||||
XPRedPacketModel *data = [XPRedPacketModel modelWithJSON:attachment.data];
|
||||
view.delegate = self;
|
||||
@@ -2183,7 +2251,10 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
NSMutableArray *redPacketList = [NSMutableArray arrayWithArray:self.sideMenu.redPacketList];
|
||||
[redPacketList insertObject:data atIndex:0];
|
||||
self.sideMenu.redPacketList = redPacketList;
|
||||
}else if(attachment.second == Custom_Message_Sub_NewRoomDiamandRedPacket){
|
||||
}
|
||||
break;
|
||||
|
||||
case Custom_Message_Sub_NewRoomDiamandRedPacket: {
|
||||
XPRedPacketModel *curData = [XPRedPacketModel modelWithJSON:attachment.data];
|
||||
if(self.sideMenu.redPacketList == nil){
|
||||
self.sideMenu.redPacketList = [NSMutableArray array];
|
||||
@@ -2210,18 +2281,28 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
[self.view bringSubviewToFront:view];
|
||||
}
|
||||
self.sideMenu.redPacketList = redPacketList;
|
||||
|
||||
}
|
||||
}else if(attachment.first == CustomMessageType_Free_Gift_Star_Reset_Time){
|
||||
if(attachment.second == Custom_Message_Sub_Free_Gift_Star_Reset_Time){
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CustomMessageType_Free_Gift_Star_Reset_Time:
|
||||
switch (attachment.second) {
|
||||
case Custom_Message_Sub_Free_Gift_Star_Reset_Time:
|
||||
[self.presenter getFreeGiftData];
|
||||
[[NSNotificationCenter defaultCenter]postNotificationName:kFreeGiftCountdownNotification object:nil userInfo:@{@"isReset":@(YES)}];
|
||||
}else if(attachment.second == Custom_Message_Sub_Update_Gift_Information){
|
||||
break;
|
||||
|
||||
case Custom_Message_Sub_Update_Gift_Information:
|
||||
[self.presenter getFreeGiftData];
|
||||
[[NSNotificationCenter defaultCenter]postNotificationName:kFreeGiftCountdownNotification object:nil userInfo:@{@"updateGiftInfo":attachment.data ?: @""}];
|
||||
}
|
||||
} else if (attachment.first == CustomMessageType_Custom_Room_Background) {
|
||||
if (attachment.second == Custom_Message_Sub_Custom_Room_Background) {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CustomMessageType_Custom_Room_Background:
|
||||
switch (attachment.second) {
|
||||
case Custom_Message_Sub_Custom_Room_Background:
|
||||
if ([attachment.data isKindOfClass:[NSDictionary class]]) {
|
||||
NSString *url = attachment.data[@"url"];
|
||||
if (![NSString isEmpty:url]) {
|
||||
@@ -2229,9 +2310,13 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
[self.backContainerView onRoomUpdate];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (attachment.first == CustomMessageType_RoomLevel_Update) {
|
||||
if (attachment.second == Custom_Message_Sub_RoomLevel_Update) {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case CustomMessageType_RoomLevel_Update:
|
||||
switch (attachment.second) {
|
||||
case Custom_Message_Sub_RoomLevel_Update:
|
||||
if ([attachment.data isKindOfClass:[NSDictionary class]]) {
|
||||
NSString *url = attachment.data[@"roomLevelIcon"];
|
||||
NSNumber *roomLevel = attachment.data[@"roomLevel"];
|
||||
@@ -2241,19 +2326,135 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
||||
self.roomInfo.roomLevelIcon = url;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if(message.messageType == NIMMessageTypeText) {
|
||||
[self.messageContainerView handleNIMTextMessage:message];
|
||||
[self.littleGameView handleNIMTextMessage:message];
|
||||
} else if(message.messageType == NIMMessageTypeTip) {
|
||||
[self.messageContainerView handleNIMTextMessage:message];
|
||||
}else if(message.messageType == NIMMessageTypeImage){
|
||||
[self.messageContainerView handleNIMImageMessage:message];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleUpMicAsk:(AttachmentModel *)attachment {
|
||||
NSNumber *targetUid = [attachment.data objectForKey:@"targetUid"];
|
||||
if (!targetUid || ![targetUid.stringValue isEqualToString:[AccountInfoStorage instance].getUid]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 先清理之前的定时器(如果存在)
|
||||
if (self.upMicAskTimer) {
|
||||
[self.upMicAskTimer invalidate];
|
||||
self.upMicAskTimer = nil;
|
||||
}
|
||||
|
||||
TTAlertConfig *config = [[TTAlertConfig alloc] init];
|
||||
config.title = YMLocalizedString(@"20.20.62_text_1");
|
||||
config.message = YMLocalizedString(@"20.20.62_text_2");
|
||||
config.actionStyle = TTAlertActionBothStyle;
|
||||
|
||||
// 自定义按钮
|
||||
config.confirmButtonConfig.title = YMLocalizedString(@"MessageContentGuildView5");
|
||||
config.cancelButtonConfig.title = YMLocalizedString(@"MessageContentGuildView4");
|
||||
|
||||
[TTPopup dismiss];
|
||||
|
||||
@kWeakify(self);
|
||||
[TTPopup alertWithConfig:config
|
||||
confirmHandler:^{
|
||||
@kStrongify(self);
|
||||
// 用户点击确认,清理定时器
|
||||
if (self.upMicAskTimer) {
|
||||
[self.upMicAskTimer invalidate];
|
||||
self.upMicAskTimer = nil;
|
||||
}
|
||||
[self sendResponseUpMicMessage:attachment.data isAgree:YES];
|
||||
} cancelHandler:^{
|
||||
@kStrongify(self);
|
||||
// 用户点击取消,清理定时器
|
||||
if (self.upMicAskTimer) {
|
||||
[self.upMicAskTimer invalidate];
|
||||
self.upMicAskTimer = nil;
|
||||
}
|
||||
[self sendResponseUpMicMessage:attachment.data isAgree:NO];
|
||||
}];
|
||||
|
||||
// 设置10秒后自动移除弹窗的定时器
|
||||
self.upMicAskTimer = [NSTimer scheduledTimerWithTimeInterval:10.0
|
||||
target:self
|
||||
selector:@selector(autoDismissUpMicAskPopup)
|
||||
userInfo:nil
|
||||
repeats:NO];
|
||||
}
|
||||
|
||||
/**
|
||||
自动移除上麦请求弹窗
|
||||
10秒后自动调用,移除弹窗并清理定时器
|
||||
*/
|
||||
- (void)autoDismissUpMicAskPopup {
|
||||
// 移除弹窗
|
||||
[TTPopup dismiss];
|
||||
|
||||
// 清理定时器
|
||||
if (self.upMicAskTimer) {
|
||||
[self.upMicAskTimer invalidate];
|
||||
self.upMicAskTimer = nil;
|
||||
}
|
||||
|
||||
NSLog(@"⏰ 上麦请求弹窗已自动移除(10秒超时)");
|
||||
}
|
||||
|
||||
- (void)handleUpMicAgree:(AttachmentModel *)attachment {
|
||||
NSDictionary *originalData = attachment.data;
|
||||
NSNumber *position = [originalData objectForKey:@"position"];
|
||||
NSNumber *targetUid = [originalData objectForKey:@"targetUid"];
|
||||
if (!position || !targetUid) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
NSMutableDictionary * dic = [NSMutableDictionary dictionary];
|
||||
[dic setValue:position forKey:@"micPosition"];
|
||||
[dic setValue:targetUid forKey:@"uid"];
|
||||
AttachmentModel *attachement = [[AttachmentModel alloc]init];
|
||||
attachement.first = CustomMessageType_Queue;
|
||||
attachement.second = Custom_Message_Sub_Queue_Invite;
|
||||
attachement.data = dic;
|
||||
|
||||
NIMMessage *message = [[NIMMessage alloc]init];
|
||||
NIMCustomObject *object = [[NIMCustomObject alloc] init];
|
||||
object.attachment = attachement;
|
||||
message.messageObject = object;
|
||||
//构造会话
|
||||
NIMSession *session = [NIMSession session: @(self.roomInfo.roomId).stringValue
|
||||
type:NIMSessionTypeChatroom];
|
||||
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
|
||||
}
|
||||
|
||||
- (void)sendResponseUpMicMessage:(NSDictionary *)originalData isAgree:(BOOL)isAgree {
|
||||
AttachmentModel *attachment = [[AttachmentModel alloc] init];
|
||||
attachment.first = ClientMessage_Type;
|
||||
attachment.second = isAgree ? ClientMessage_UpMic_Agree : ClientMessage_UpMic_Reject;
|
||||
attachment.data = originalData;
|
||||
|
||||
NSString *sessionID = @(self.roomInfo.roomId).stringValue;
|
||||
NIMMessage *message = [[NIMMessage alloc]init];
|
||||
NIMCustomObject *object = [[NIMCustomObject alloc] init];
|
||||
object.attachment = attachment;
|
||||
message.messageObject = object;
|
||||
|
||||
NIMSessionType sessionType = NIMSessionTypeChatroom;
|
||||
//构造会话
|
||||
NIMSession *session = [NIMSession session:sessionID type:sessionType];
|
||||
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session completion:^(NSError * _Nullable error) {
|
||||
BOOL onMain = [NSThread isMainThread];
|
||||
if (error) {
|
||||
NSLog(@"[[Send] ❌ 发送失败 | sessionId=%@ | code=%ld | desc=%@ | main=%@ | ts=%.3f",
|
||||
sessionID, (long)error.code, error.localizedDescription, onMain ? @"YES" : @"NO", [[NSDate date] timeIntervalSince1970]);
|
||||
} else {
|
||||
NSLog(@"[Send] ✅ 发送成功 | sessionId=%@ | main=%@ | ts=%.3f",
|
||||
sessionID, onMain ? @"YES" : @"NO", [[NSDate date] timeIntervalSince1970]);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - NIMBroadcastDelegate
|
||||
// 广播消息
|
||||
- (void)onReceiveBroadcastMessage:(NIMBroadcastMessage *)broadcastMessage{
|
||||
|
@@ -4226,3 +4226,12 @@ ineHeadView12" = "الحمل";
|
||||
"20.20.61_text_17" = "نصيحة مقعد الميدالية";
|
||||
"20.20.61_text_18" = "قم بالترقية الآن!";
|
||||
"20.20.61_text_19" = "بونص";
|
||||
|
||||
"20.20.62_text_1" = "دعوة الميكروفون";
|
||||
"20.20.62_text_2" = "يدعوك المضيف/المسؤول للانضمام إلى الدردشة!";
|
||||
"20.20.62_text_3" = "تم إرسال الدعوة بنجاح.";
|
||||
"20.20.62_text_4" = "رفض الطرف الآخر دعوتك.";
|
||||
"20.20.62_text_5" = "غادر المستخدم، فشلت الدعوة.";
|
||||
"20.20.62_text_6" = "الميكروفون مشغول. يُرجى المحاولة لاحقًا.";
|
||||
"20.20.62_text_7" = "ليس لديك إذن لدعوة المستخدم إلى الميكروفون.";
|
||||
"20.20.62_text_8" = "فشل إرسال الدعوة. يُرجى التحقق من الشبكة.";
|
||||
|
@@ -4013,3 +4013,12 @@
|
||||
"20.20.61_text_17" = "Medal Seat Tip";
|
||||
"20.20.61_text_18" = "Upgrade now!";
|
||||
"20.20.61_text_19" = "Bonus";
|
||||
|
||||
"20.20.62_text_1" = "Mic Invitation";
|
||||
"20.20.62_text_2" = "The host/admin invites you up to mic to join the chat!";
|
||||
"20.20.62_text_3" = "You have successfully sent the invitation.";
|
||||
"20.20.62_text_4" = "The other party has declined your invitation.";
|
||||
"20.20.62_text_5" = "The user has left, invitation failed.";
|
||||
"20.20.62_text_6" = "The mic is occupied. Please try again later.";
|
||||
"20.20.62_text_7" = "You do not have permission to invite the user to the mic.";
|
||||
"20.20.62_text_8" = "The invitation failed to be sent. Please check the network.";
|
||||
|
@@ -3307,3 +3307,11 @@
|
||||
"20.20.61_text_18" = "Atualize agora!";
|
||||
"20.20.61_text_19" = "Bônus";
|
||||
|
||||
"20.20.62_text_1" = "Convite para Microfone";
|
||||
"20.20.62_text_2" = "O anfitrião/administrador convida você para o microfone para participar do bate-papo!";
|
||||
"20.20.62_text_3" = "Você enviou o convite com sucesso.";
|
||||
"20.20.62_text_4" = "A outra parte recusou o seu convite.";
|
||||
"20.20.62_text_5" = "O usuário saiu, o convite falhou.";
|
||||
"20.20.62_text_6" = "O microfone está ocupado. Tente novamente mais tarde.";
|
||||
"20.20.62_text_7" = "Você não tem permissão para convidar o usuário para o microfone.";
|
||||
"20.20.62_text_8" = "O convite não foi enviado. Verifique a rede.";
|
||||
|
@@ -3807,3 +3807,12 @@
|
||||
"20.20.61_text_17" = "Madalya Koltuğu İpucu";
|
||||
"20.20.61_text_18" = "Şimdi yükseltin!";
|
||||
"20.20.61_text_19" = "Bonus";
|
||||
|
||||
"20.20.62_text_1" = "Mikrofon Daveti";
|
||||
"20.20.62_text_2" = "Sohbete katılmanız için ev sahibi/yönetici sizi mikrofona davet ediyor!";
|
||||
"20.20.62_text_3" = "Davetiyeyi başarıyla gönderdiniz.";
|
||||
"20.20.62_text_4" = "Karşı taraf davetinizi reddetti.";
|
||||
"20.20.62_text_5" = "Kullanıcı ayrıldı, davet başarısız oldu.";
|
||||
"20.20.62_text_6" = "Mikrofon meşgul. Lütfen daha sonra tekrar deneyin.";
|
||||
"20.20.62_text_7" = "Kullanıcıyı mikrofona davet etme izniniz yok.";
|
||||
"20.20.62_text_8" = "Davet gönderilemedi. Lütfen ağı kontrol edin.";
|
||||
|
@@ -3677,3 +3677,12 @@
|
||||
"20.20.61_text_17" = "獎牌座位提示";
|
||||
"20.20.61_text_18" = "立即升級!";
|
||||
"20.20.61_text_19" = "額外獎勵";
|
||||
|
||||
"20.20.62_text_1" = "上麦邀请";
|
||||
"20.20.62_text_2" = "房主/管理员 邀请你上麦一起聊天!";
|
||||
"20.20.62_text_3" = "你已经成功发送邀请。";
|
||||
"20.20.62_text_4" = "对方拒绝了你的邀请";
|
||||
"20.20.62_text_5" = "用戶已離開,邀請失敗。";
|
||||
"20.20.62_text_6" = "麥克風已被佔用,請稍後再試。";
|
||||
"20.20.62_text_7" = "您無權邀請該使用者加入麥克風。";
|
||||
"20.20.62_text_8" = "邀請發送失敗,請檢查網路。";
|
||||
|
Reference in New Issue
Block a user