This commit is contained in:
启星
2025-11-21 16:17:05 +08:00
parent 7ac937ddbf
commit 8913ea6f48
283 changed files with 8474 additions and 800 deletions

View File

@@ -13,6 +13,7 @@
#import <AgoraRtcKit/AgoraRtcEngineKit.h>
#import "TUIChatConfig.h"
#import "QXDrifNobilityJoinRoomView.h"
#import "QXCustomAlertView.h"
@interface QXRoomMessageManager() <V2TIMGroupListener,V2TIMSimpleMsgListener,V2TIMAdvancedMsgListener>
@property (nonatomic,strong)NSString *groupId;
@@ -34,13 +35,15 @@
}
return self;
}
-(void)addC2CObserver{
[[V2TIMManager sharedInstance] addSimpleMsgListener:self];
}
-(void)joinGroupWithRoomId:(NSString *)roomId{
MJWeakSelf
if (self.groupId) {
[self quitGroupWithRoomId:self.groupId];
}
[[V2TIMManager sharedInstance] addGroupListener:self];
[[V2TIMManager sharedInstance] addSimpleMsgListener:self];
[[V2TIMManager sharedInstance] addAdvancedMsgListener:self];
NSString *groupId = [NSString stringWithFormat:@"room%@",roomId];
[[V2TIMManager sharedInstance] joinGroup:groupId msg:@"大家好,我来啦" succ:^{
@@ -57,7 +60,6 @@
self.groupId = nil;
self.roomId = nil;
[[V2TIMManager sharedInstance] removeGroupListener:self];
[[V2TIMManager sharedInstance] removeSimpleMsgListener:self];
[[V2TIMManager sharedInstance] removeAdvancedMsgListener:self];
NSString *groupId = [NSString stringWithFormat:@"room%@",roomId];
[[V2TIMManager sharedInstance] quitGroup:groupId succ:^{
@@ -653,6 +655,28 @@
}
}
break;
case QXRoomMessageTypeSingerRoomCurrentSongDidChanged:{
QXUserSongListModel *songInfo = [QXUserSongListModel yy_modelWithJSON:msg.Text[@"song_info"]];
if (self.delegate && [self.delegate respondsToSelector:@selector(singerSongCurrentSongInfoDidChanged:)]) {
[self.delegate singerSongCurrentSongInfoDidChanged:songInfo];
}
}
break;
case QXRoomMessageTypeSingerRoomNextSongDidChanged:{
QXUserSongListModel *songInfo = [QXUserSongListModel yy_modelWithJSON:msg.Text[@"next_song_info"]];
if (self.delegate && [self.delegate respondsToSelector:@selector(singerSongNextSongInfoDidChanged:)]) {
[self.delegate singerSongNextSongInfoDidChanged:songInfo];
}
}
break;
case QXRoomMessageTypeSingerRoomSongCountDidChanged:{
NSString *songCount = [NSString stringWithFormat:@"%@",msg.Text[@"count"]];
if (self.delegate && [self.delegate respondsToSelector:@selector(singerSongCountDidChanged:)]) {
[self.delegate singerSongCountDidChanged:songCount];
}
}
break;
default:
break;
}
@@ -672,6 +696,42 @@
*/
-(void)reSendGiftWithId:(NSString*)giftId userId:(NSString*)userId{
MJWeakSelf
[QXMineNetwork userCpReSendWithGiftId:giftId userId:userId roomId:self.roomId successBlock:^(NSDictionary * _Nonnull dict) {
id object = dict[@"cp_type"];
if ([object isKindOfClass:[NSDictionary class]]) {
NSDictionary *cpDict = (NSDictionary *)object;
NSString *cp_type = object[@"cp_type"];
if (cp_type.intValue == 1) {
/// cp
NSString *jsonStr = [cpDict jsonStringEncoded];
[[QXRoomMessageManager shared] sendC2CMessage:jsonStr messageType:(QXRoomMessageTypeSendAndRecieveCpHeartSignal) userId:userId];
}else if (cp_type.intValue == 2){
/// cp
NSString *jsonStr = [cpDict jsonStringEncoded];
[[QXRoomMessageManager shared] sendC2CMessage:jsonStr messageType:(QXRoomMessageTypeCpHeartFinished) userId:userId];
NSString *message = [NSString stringWithFormat:@"%@",cpDict[@"text"]];
[weakSelf showCpFinishedAlertViewWithText:message];
}else{
}
}
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
showToast(msg);
}];
}
-(void)showCpFinishedAlertViewWithText:(NSString*)text{
QXCustomAlertView *alertView = [[QXCustomAlertView alloc] init];
[alertView showInView:KEYWINDOW title:@"缘定三生 此刻同心" message:text cancleTitle:@"稍后进入" commitTitle:@"进入心动空间"];
alertView.commitBlock = ^{
QXLOG(@"进入心动空间");
};
}
-(void)onRecvC2CTextMessage:(NSString *)msgID sender:(V2TIMUserInfo *)info text:(NSString *)text{
@@ -688,6 +748,23 @@
if (self.delegate && [self.delegate respondsToSelector:@selector(pkMuteRemoteAudio:fromUserInfo:)]) {
[self.delegate pkMuteRemoteAudio:is_mute==1 fromUserInfo:model.FromUserInfo];
}
}else if (meesageType == QXRoomMessageTypeSendAndRecieveCpHeartSignal){
NSString *json = [NSString stringWithFormat:@"%@",msg.Text[@"text"]];
NSDictionary *dict = [json jsonValueDecoded];
NSString *message = [NSString stringWithFormat:@"%@",dict[@"text1"]];
__block NSString *gift_id = [NSString stringWithFormat:@"%@",dict[@"gift_id"]];
QXRoomChatListModel *model = [QXRoomChatListModel yy_modelWithJSON:msg.Text];
QXCustomAlertView *alertView = [[QXCustomAlertView alloc] init];
[alertView showInView:KEYWINDOW title:@"心动信号" message:message cancleTitle:@"再想想" commitTitle:@"回赠"];
MJWeakSelf
alertView.commitBlock = ^{
[weakSelf reSendGiftWithId:gift_id userId:model.FromUserInfo.user_id];
};
}else if (meesageType == QXRoomMessageTypeCpHeartFinished){
NSString *json = [NSString stringWithFormat:@"%@",msg.Text[@"text"]];
NSDictionary *dict = [json jsonValueDecoded];
NSString *message = [NSString stringWithFormat:@"%@",dict[@"text1"]];
[self showCpFinishedAlertViewWithText:message];
}
}
-(void)onRecvGroupCustomMessage:(NSString *)msgID groupID:(NSString *)groupID sender:(V2TIMGroupMemberInfo *)info customData:(NSData *)data{
@@ -719,7 +796,7 @@
}else if (meesageType == QXRoomMessageTypeMuteLocalAudio){
NSString *json = [NSString stringWithFormat:@"%@",msg.Text[@"text"]];
NSDictionary *dict = [json jsonValueDecoded];
NSInteger is_mute = [[dict objectForKey:@"is_mute"] integerValue];
// NSInteger is_mute = [[dict objectForKey:@"is_mute"] integerValue];
QXUserHomeModel *userModel = [QXUserHomeModel yy_modelWithJSON:msg.Text[@"FromUserInfo"]];
AgoraRtcAudioVolumeInfo *userInfo = [[AgoraRtcAudioVolumeInfo alloc] init];
userInfo.uid = userModel.user_id.longLongValue;
@@ -855,9 +932,9 @@
[[V2TIMManager sharedInstance] sendMessage:message1 receiver:toUserId groupID:nil priority:(V2TIM_PRIORITY_HIGH) onlineUserOnly:YES offlinePushInfo:nil progress:^(uint32_t progress) {
} succ:^{
QXLOG(@"c2c发送成功");
} fail:^(int code, NSString * _Nullable desc) {
QXLOG(@"c2c发送失败");
}];
}
@end