更新 Podfile 中 NIMSDK_LITE 版本至 '~> 10.9.40',并在多个文件中新增日志记录功能以优化连击消息处理,增强调试能力。同时,新增连击计数重置通知和相关方法,提升用户体验和代码可维护性。

This commit is contained in:
edwinQQQ
2025-08-18 19:02:47 +08:00
parent 9688e4413b
commit f1daa16e59
7 changed files with 117 additions and 7 deletions

View File

@@ -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'

View File

@@ -1132,6 +1132,8 @@ UIGestureRecognizerDelegate
return;
}
// combo
[[GiftComboManager sharedManager] receiveGiftInfoForDisplayComboFlags:receiveInfo
container:self];
@@ -1582,6 +1584,16 @@ UIGestureRecognizerDelegate
}
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
{
// first/secondpayload 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

View File

@@ -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] 📱 触发连击面板显示回调");

View File

@@ -142,6 +142,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) NSInteger bgLevel; // 1,2,3 对应非 VIP 背景456 对应 VIP 背景
- (NSInteger)receiveUserCount;
- (void)giftDataAlignment;

View File

@@ -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];

View File

@@ -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]);
}
}];
}

View File

@@ -2041,6 +2041,11 @@ 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) {
@@ -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;