更新 Podfile 中 NIMSDK_LITE 版本至 '~> 10.9.40',并在多个文件中新增日志记录功能以优化连击消息处理,增强调试能力。同时,新增连击计数重置通知和相关方法,提升用户体验和代码可维护性。
This commit is contained in:
2
Podfile
2
Podfile
@@ -50,7 +50,7 @@ target 'YuMi' do
|
|||||||
#pop动画
|
#pop动画
|
||||||
pod 'pop'
|
pod 'pop'
|
||||||
#云信
|
#云信
|
||||||
pod 'NIMSDK_LITE'
|
pod 'NIMSDK_LITE', '~> 10.9.40'
|
||||||
pod 'GKCycleScrollView'
|
pod 'GKCycleScrollView'
|
||||||
pod 'SVGAPlayer'
|
pod 'SVGAPlayer'
|
||||||
pod 'GoogleSignIn'
|
pod 'GoogleSignIn'
|
||||||
|
@@ -1132,6 +1132,8 @@ UIGestureRecognizerDelegate
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 处理 combo
|
// 处理 combo
|
||||||
[[GiftComboManager sharedManager] receiveGiftInfoForDisplayComboFlags:receiveInfo
|
[[GiftComboManager sharedManager] receiveGiftInfoForDisplayComboFlags:receiveInfo
|
||||||
container:self];
|
container:self];
|
||||||
@@ -1582,6 +1584,16 @@ UIGestureRecognizerDelegate
|
|||||||
}
|
}
|
||||||
|
|
||||||
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
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) {
|
switch (attachment.first) {
|
||||||
case CustomMessageType_User_Enter_Room:
|
case CustomMessageType_User_Enter_Room:
|
||||||
[self _handleEnterRoomMessage:message];
|
[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);
|
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 ||
|
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_Gift_LuckySend ||
|
||||||
attachment.second == Custom_Message_Sub_AllMicroLuckySend ||
|
attachment.second == Custom_Message_Sub_AllMicroLuckySend ||
|
||||||
attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
|
attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
|
||||||
@@ -3494,4 +3510,6 @@ UIGestureRecognizerDelegate
|
|||||||
self.savedTapPoint = CGPointZero;
|
self.savedTapPoint = CGPointZero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -124,6 +124,9 @@ NSString * const kBoomStateForceResetNotification = @"BoomStateForceResetNotific
|
|||||||
// 验证重置后的状态
|
// 验证重置后的状态
|
||||||
NSLog(@"[Combo effect] 🔍 重置后验证 - combo: %ld", (long)self.combo);
|
NSLog(@"[Combo effect] 🔍 重置后验证 - combo: %ld", (long)self.combo);
|
||||||
|
|
||||||
|
// 发送通知,让 GiftComboView 重置显示
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"ComboCountReset" object:nil];
|
||||||
|
|
||||||
// 检查是否应该显示连击面板
|
// 检查是否应该显示连击面板
|
||||||
if (self.actionCallback && self.enableCombo) {
|
if (self.actionCallback && self.enableCombo) {
|
||||||
NSLog(@"[Combo effect] 📱 触发连击面板显示回调");
|
NSLog(@"[Combo effect] 📱 触发连击面板显示回调");
|
||||||
|
@@ -142,6 +142,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
|
|
||||||
@property (nonatomic, assign) NSInteger bgLevel; // 1,2,3 对应非 VIP 背景,456 对应 VIP 背景
|
@property (nonatomic, assign) NSInteger bgLevel; // 1,2,3 对应非 VIP 背景,456 对应 VIP 背景
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- (NSInteger)receiveUserCount;
|
- (NSInteger)receiveUserCount;
|
||||||
|
|
||||||
- (void)giftDataAlignment;
|
- (void)giftDataAlignment;
|
||||||
|
@@ -30,8 +30,6 @@
|
|||||||
|
|
||||||
@property (nonatomic, strong) NSTimer *longPressTimer;
|
@property (nonatomic, strong) NSTimer *longPressTimer;
|
||||||
|
|
||||||
//@property (nonatomic, strong) dispatch_queue_t animationQueue; // 串行队列,确保线程安全
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@@ -108,6 +106,16 @@
|
|||||||
[self handleDictionaryNotification:notification.object];
|
[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 {
|
- (void)handleStringNotification:(NSString *)coin {
|
||||||
@@ -125,7 +133,7 @@
|
|||||||
|
|
||||||
- (void)updateCount {
|
- (void)updateCount {
|
||||||
// 在连击面板点击时,需要先更新连击计数
|
// 在连击面板点击时,需要先更新连击计数
|
||||||
NSInteger comboCount = [[GiftComboManager sharedManager] loadComboCountFromSendGiftView];
|
NSInteger comboCount = [[GiftComboManager sharedManager] loadComboCount];
|
||||||
NSLog(@"[Combo effect] 🔢 更新连击次数显示 - combo: %ld", (long)comboCount);
|
NSLog(@"[Combo effect] 🔢 更新连击次数显示 - combo: %ld", (long)comboCount);
|
||||||
NSString *countStr = [NSString stringWithFormat:@"x%ld", comboCount];
|
NSString *countStr = [NSString stringWithFormat:@"x%ld", comboCount];
|
||||||
NSShadow *shadow = [[NSShadow alloc] init];
|
NSShadow *shadow = [[NSShadow alloc] init];
|
||||||
@@ -142,6 +150,36 @@
|
|||||||
[[GiftComboManager sharedManager] printComboState];
|
[[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 {
|
- (void)stopTimer {
|
||||||
[self.countdownRingView stopCountdown];
|
[self.countdownRingView stopCountdown];
|
||||||
}
|
}
|
||||||
@@ -233,6 +271,11 @@
|
|||||||
[self.feedbackGenerator impactOccurred];
|
[self.feedbackGenerator impactOccurred];
|
||||||
|
|
||||||
NSLog(@"[Combo effect] 👆 连击面板被点击,发送礼物");
|
NSLog(@"[Combo effect] 👆 连击面板被点击,发送礼物");
|
||||||
|
|
||||||
|
// 在发送礼物前,先递增 combo 计数并更新显示
|
||||||
|
NSInteger comboCount = [[GiftComboManager sharedManager] loadComboCountFromSendGiftView];
|
||||||
|
[self updateCountWithCombo:comboCount];
|
||||||
|
|
||||||
[[GiftComboManager sharedManager] sendGift];
|
[[GiftComboManager sharedManager] sendGift];
|
||||||
[self.playImageView startAnimation];
|
[self.playImageView startAnimation];
|
||||||
[self.countdownRingView resetCountdown];
|
[self.countdownRingView resetCountdown];
|
||||||
|
@@ -128,6 +128,8 @@ UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma mark - 连击状态管理
|
#pragma mark - 连击状态管理
|
||||||
|
|
||||||
// 移除连击相关视图
|
// 移除连击相关视图
|
||||||
@@ -237,6 +239,8 @@ UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification;
|
|||||||
name:kBoomStateForceResetNotification
|
name:kBoomStateForceResetNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
// 注册调试通知
|
// 注册调试通知
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
@@ -582,7 +586,21 @@ UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification;
|
|||||||
|
|
||||||
// 连击计数应该从 attachment.data 中获取,而不是重新计算
|
// 连击计数应该从 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];
|
attachment.data = [self removeNSNullValuesAndEmptyStringsRecursively:attachment.data];
|
||||||
|
|
||||||
@@ -601,8 +619,13 @@ UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification;
|
|||||||
//构造会话
|
//构造会话
|
||||||
NIMSession *session = [NIMSession session:sessionID type:sessionType];
|
NIMSession *session = [NIMSession session:sessionID type:sessionType];
|
||||||
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session completion:^(NSError * _Nullable error) {
|
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session completion:^(NSError * _Nullable error) {
|
||||||
|
BOOL onMain = [NSThread isMainThread];
|
||||||
if (error) {
|
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]);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
@@ -2041,6 +2041,11 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
|
- (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) {
|
for (NIMMessage * message in messages) {
|
||||||
///房间内收到p2p的消息 比如升级消息
|
///房间内收到p2p的消息 比如升级消息
|
||||||
if (message.session.sessionType == NIMSessionTypeP2P) {
|
if (message.session.sessionType == NIMSessionTypeP2P) {
|
||||||
@@ -2060,12 +2065,16 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 非房间内消息不处理
|
// 非房间内消息不处理(记录过滤原因)
|
||||||
if (message.session.sessionType != NIMSessionTypeChatroom) {
|
if (message.session.sessionType != NIMSessionTypeChatroom) {
|
||||||
|
NSLog(@"[Combo effect][Recv] ⛔️ 过滤:非聊天室消息 | type=%ld | sid=%@",
|
||||||
|
(long)message.session.sessionType, message.session.sessionId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (![message.session.sessionId isEqualToString:@(self.roomInfo.roomId).stringValue]) {
|
if (![message.session.sessionId isEqualToString:@(self.roomInfo.roomId).stringValue]) {
|
||||||
|
NSLog(@"[Combo effect][Recv] ⛔️ 过滤:房间不匹配 | msg.sid=%@ | curRoomId=%@",
|
||||||
|
message.session.sessionId, @(self.roomInfo.roomId).stringValue);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2246,6 +2255,18 @@ XPCandyTreeInsufficientBalanceViewDelegate>
|
|||||||
[XPSkillCardPlayerManager shareInstance].isMineInMic = NO;
|
[XPSkillCardPlayerManager shareInstance].isMineInMic = NO;
|
||||||
};
|
};
|
||||||
} else if (message.messageType == NIMMessageTypeCustom) {
|
} 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;
|
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||||
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
||||||
AttachmentModel * attachment = (AttachmentModel *)obj.attachment;
|
AttachmentModel * attachment = (AttachmentModel *)obj.attachment;
|
||||||
|
Reference in New Issue
Block a user