From f1daa16e5953dc67adce91a9cce4146a9e096689 Mon Sep 17 00:00:00 2001 From: edwinQQQ Date: Mon, 18 Aug 2025 19:02:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Podfile=20=E4=B8=AD=20NIMS?= =?UTF-8?q?DK=5FLITE=20=E7=89=88=E6=9C=AC=E8=87=B3=20'~>=2010.9.40'?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E5=9C=A8=E5=A4=9A=E4=B8=AA=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E6=96=B0=E5=A2=9E=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BB=A5=E4=BC=98=E5=8C=96=E8=BF=9E=E5=87=BB?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86=EF=BC=8C=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E8=83=BD=E5=8A=9B=E3=80=82=E5=90=8C=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=BF=9E=E5=87=BB=E8=AE=A1=E6=95=B0?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=E9=80=9A=E7=9F=A5=E5=92=8C=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=96=B9=E6=B3=95=EF=BC=8C=E6=8F=90=E5=8D=87=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BD=93=E9=AA=8C=E5=92=8C=E4=BB=A3=E7=A0=81=E5=8F=AF=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Podfile | 2 +- .../View/AnimationView/RoomAnimationView.m | 18 +++++++ .../View/SendGiftView/GiftComboManager.m | 3 ++ .../SendGiftView/Model/GiftReceiveInfoModel.h | 2 + .../View/SendGiftView/View/GiftComboView.m | 49 +++++++++++++++++-- .../View/SendGiftView/View/XPSendGiftView.m | 27 +++++++++- .../YMRoom/View/XPRoomViewController.m | 23 ++++++++- 7 files changed, 117 insertions(+), 7 deletions(-) diff --git a/Podfile b/Podfile index 9e261d2f..87891038 100644 --- a/Podfile +++ b/Podfile @@ -50,7 +50,7 @@ target 'YuMi' do #pop动画 pod 'pop' #云信 - pod 'NIMSDK_LITE' + pod 'NIMSDK_LITE', '~> 10.9.40' pod 'GKCycleScrollView' pod 'SVGAPlayer' pod 'GoogleSignIn' diff --git a/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m b/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m index e5007379..d4daf964 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/RoomAnimationView.m @@ -1132,6 +1132,8 @@ UIGestureRecognizerDelegate return; } + + // 处理 combo [[GiftComboManager sharedManager] receiveGiftInfoForDisplayComboFlags:receiveInfo container:self]; @@ -1582,6 +1584,16 @@ UIGestureRecognizerDelegate } AttachmentModel *attachment = (AttachmentModel *)obj.attachment; + { + // 自定义消息处理入口排查日志:first/second、payload size、线程 + NSData *payloadJSON = nil; + @try { payloadJSON = [NSJSONSerialization dataWithJSONObject:attachment.data ?: @{} options:0 error:nil]; } @catch (__unused NSException *e) {} + NSLog(@"[Combo effect][Anim] 🎞 handleNIMCustomMessage | first=%ld second=%ld | payload=%lub | main=%@ | ts=%.3f", + (long)attachment.first, (long)attachment.second, + (unsigned long)payloadJSON.length, + [NSThread isMainThread] ? @"YES" : @"NO", + [[NSDate date] timeIntervalSince1970]); + } switch (attachment.first) { case CustomMessageType_User_Enter_Room: [self _handleEnterRoomMessage:message]; @@ -1740,8 +1752,12 @@ UIGestureRecognizerDelegate } } + + NSLog(@"[Combo effect] 📨 礼物消息解析完成 - giftId: %ld, combo: %ld, uid: %@", (long)receiveInfo.gift.giftId, (long)receiveInfo.comboCount, receiveInfo.uid); + + receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_Gift_LuckySend || attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend); @@ -3494,4 +3510,6 @@ UIGestureRecognizerDelegate self.savedTapPoint = CGPointZero; } + + @end diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/GiftComboManager.m b/YuMi/Modules/YMRoom/View/SendGiftView/GiftComboManager.m index 54448f10..b3ccbdc1 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/GiftComboManager.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/GiftComboManager.m @@ -124,6 +124,9 @@ NSString * const kBoomStateForceResetNotification = @"BoomStateForceResetNotific // 验证重置后的状态 NSLog(@"[Combo effect] 🔍 重置后验证 - combo: %ld", (long)self.combo); + // 发送通知,让 GiftComboView 重置显示 + [[NSNotificationCenter defaultCenter] postNotificationName:@"ComboCountReset" object:nil]; + // 检查是否应该显示连击面板 if (self.actionCallback && self.enableCombo) { NSLog(@"[Combo effect] 📱 触发连击面板显示回调"); diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/Model/GiftReceiveInfoModel.h b/YuMi/Modules/YMRoom/View/SendGiftView/Model/GiftReceiveInfoModel.h index fdc78844..bef17415 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/Model/GiftReceiveInfoModel.h +++ b/YuMi/Modules/YMRoom/View/SendGiftView/Model/GiftReceiveInfoModel.h @@ -142,6 +142,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign) NSInteger bgLevel; // 1,2,3 对应非 VIP 背景,456 对应 VIP 背景 + + - (NSInteger)receiveUserCount; - (void)giftDataAlignment; diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboView.m index 2b159efa..17ab134b 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboView.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboView.m @@ -30,8 +30,6 @@ @property (nonatomic, strong) NSTimer *longPressTimer; -//@property (nonatomic, strong) dispatch_queue_t animationQueue; // 串行队列,确保线程安全 - @end @@ -108,6 +106,16 @@ [self handleDictionaryNotification:notification.object]; } }]; + + // 监听连击计数重置通知 + [[NSNotificationCenter defaultCenter] addObserverForName:@"ComboCountReset" + object:nil + queue:[NSOperationQueue mainQueue] + usingBlock:^(NSNotification * _Nonnull notification) { + @kStrongify(self); + NSLog(@"[Combo effect] 📢 收到连击计数重置通知"); + [self resetComboCount]; + }]; } - (void)handleStringNotification:(NSString *)coin { @@ -125,7 +133,7 @@ - (void)updateCount { // 在连击面板点击时,需要先更新连击计数 - NSInteger comboCount = [[GiftComboManager sharedManager] loadComboCountFromSendGiftView]; + NSInteger comboCount = [[GiftComboManager sharedManager] loadComboCount]; NSLog(@"[Combo effect] 🔢 更新连击次数显示 - combo: %ld", (long)comboCount); NSString *countStr = [NSString stringWithFormat:@"x%ld", comboCount]; NSShadow *shadow = [[NSShadow alloc] init]; @@ -142,6 +150,36 @@ [[GiftComboManager sharedManager] printComboState]; } +// 新增方法:重置连击计数显示 +- (void)resetComboCount { + NSLog(@"[Combo effect] 🔄 重置连击计数显示"); + NSString *countStr = @"x1"; // 重置为 x1 + NSShadow *shadow = [[NSShadow alloc] init]; + shadow.shadowBlurRadius = 3; + shadow.shadowColor = [UIColor colorWithRed:255/255.0 green:153./255.0 blue:0/255.0 alpha:1]; + shadow.shadowOffset =CGSizeMake(0,1); + NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:countStr + attributes: @{NSFontAttributeName: kFontSemibold(30), + NSForegroundColorAttributeName: UIColorFromRGB(0xFFE07B), + NSShadowAttributeName: shadow}]; + self.comboCountLabel.attributedText = string; +} + +// 新增方法:使用指定的 combo 计数更新显示 +- (void)updateCountWithCombo:(NSInteger)comboCount { + NSLog(@"[Combo effect] 🔢 使用指定计数更新连击次数显示 - combo: %ld", (long)comboCount); + NSString *countStr = [NSString stringWithFormat:@"x%ld", comboCount]; + NSShadow *shadow = [[NSShadow alloc] init]; + shadow.shadowBlurRadius = 3; + shadow.shadowColor = [UIColor colorWithRed:255/255.0 green:153./255.0 blue:0/255.0 alpha:1]; + shadow.shadowOffset =CGSizeMake(0,1); + NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:countStr + attributes: @{NSFontAttributeName: kFontSemibold(30), + NSForegroundColorAttributeName: UIColorFromRGB(0xFFE07B), + NSShadowAttributeName: shadow}]; + self.comboCountLabel.attributedText = string; +} + - (void)stopTimer { [self.countdownRingView stopCountdown]; } @@ -233,6 +271,11 @@ [self.feedbackGenerator impactOccurred]; NSLog(@"[Combo effect] 👆 连击面板被点击,发送礼物"); + + // 在发送礼物前,先递增 combo 计数并更新显示 + NSInteger comboCount = [[GiftComboManager sharedManager] loadComboCountFromSendGiftView]; + [self updateCountWithCombo:comboCount]; + [[GiftComboManager sharedManager] sendGift]; [self.playImageView startAnimation]; [self.countdownRingView resetCountdown]; diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m index d935dd45..41c811ef 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m @@ -128,6 +128,8 @@ UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification; } } + + #pragma mark - 连击状态管理 // 移除连击相关视图 @@ -237,6 +239,8 @@ UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification; name:kBoomStateForceResetNotification object:nil]; + + #if DEBUG // 注册调试通知 [[NSNotificationCenter defaultCenter] addObserver:self @@ -582,7 +586,21 @@ UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification; // 连击计数应该从 attachment.data 中获取,而不是重新计算 // 这样可以避免重复递增连击计数 - NSLog(@"[Combo effect] 📨 发送云信消息 - 连击计数: %@", attachment.data[@"comboCount"]); + { + BOOL onMain = [NSThread isMainThread]; + NSInteger comboToSend = [attachment.data[@"comboCount"] integerValue]; + NSData *payloadJSON = nil; + @try { + payloadJSON = [NSJSONSerialization dataWithJSONObject:attachment.data ?: @{} options:0 error:nil]; + } @catch (__unused NSException *e) {} + NSLog(@"[Combo effect][Send] 📨 即将发送 | sessionId=%@ type=%@ | combo=%ld | payload=%lub | main=%@ | ts=%.3f", + sessionID, + (self.usingplaceType == SendGiftType_Room ? @"Chatroom" : @"P2P"), + (long)comboToSend, + (unsigned long)(payloadJSON.length), + onMain ? @"YES" : @"NO", + [[NSDate date] timeIntervalSince1970]); + } attachment.data = [self removeNSNullValuesAndEmptyStringsRecursively:attachment.data]; @@ -601,8 +619,13 @@ UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification; //构造会话 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(@"%@",error); + NSLog(@"[Combo effect][Send] ❌ 发送失败 | sessionId=%@ | code=%ld | desc=%@ | main=%@ | ts=%.3f", + sessionID, (long)error.code, error.localizedDescription, onMain ? @"YES" : @"NO", [[NSDate date] timeIntervalSince1970]); + } else { + NSLog(@"[Combo effect][Send] ✅ 发送成功 | sessionId=%@ | main=%@ | ts=%.3f", + sessionID, onMain ? @"YES" : @"NO", [[NSDate date] timeIntervalSince1970]); } }]; } diff --git a/YuMi/Modules/YMRoom/View/XPRoomViewController.m b/YuMi/Modules/YMRoom/View/XPRoomViewController.m index 1454930d..cb8e2164 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomViewController.m +++ b/YuMi/Modules/YMRoom/View/XPRoomViewController.m @@ -2041,6 +2041,11 @@ XPCandyTreeInsufficientBalanceViewDelegate> } - (void)onRecvMessages:(NSArray *)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) { @@ -2060,12 +2065,16 @@ XPCandyTreeInsufficientBalanceViewDelegate> } } - // 非房间内消息不处理 + // 非房间内消息不处理(记录过滤原因) if (message.session.sessionType != NIMSessionTypeChatroom) { + NSLog(@"[Combo effect][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=%@", + message.session.sessionId, @(self.roomInfo.roomId).stringValue); continue; } @@ -2246,6 +2255,18 @@ XPCandyTreeInsufficientBalanceViewDelegate> [XPSkillCardPlayerManager shareInstance].isMineInMic = NO; }; } else if (message.messageType == NIMMessageTypeCustom) { + // 自定义消息排查日志:first/second/size + 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", + (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;