提交
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
@interface QXRoomMessageManager() <V2TIMGroupListener,V2TIMSimpleMsgListener,V2TIMAdvancedMsgListener>
|
||||
@property (nonatomic,strong)NSString *groupId;
|
||||
@property (nonatomic,strong)NSString *roomId;
|
||||
@property (nonatomic,strong)NSString *exRoomId;
|
||||
@property (nonatomic,strong)NSString *exGroupId;
|
||||
@end
|
||||
@implementation QXRoomMessageManager
|
||||
+ (instancetype)shared {
|
||||
@@ -60,6 +62,24 @@
|
||||
[QXLogger infoWithTag:@"房间日志" format:@"腾讯IM加入聊天室失败-code%d-原因%@",code,desc];
|
||||
}];
|
||||
}
|
||||
-(void)joinExGroupWithRoomId:(NSString *)roomId{
|
||||
[[V2TIMManager sharedInstance] addGroupListener:self];
|
||||
[[V2TIMManager sharedInstance] addAdvancedMsgListener:self];
|
||||
NSString *exGroupId = [NSString stringWithFormat:@"room%@",roomId];
|
||||
self.exGroupId = exGroupId;
|
||||
self.exRoomId = roomId;
|
||||
[[V2TIMManager sharedInstance] joinGroup:exGroupId msg:@"大家好,我来啦" succ:^{
|
||||
QXLOG(@"腾讯IM小黑屋加入聊天室成功");
|
||||
// weakSelf.groupId = groupId;
|
||||
// weakSelf.roomId = roomId;
|
||||
[QXLogger infoWithTag:@"房间日志" format:@"腾讯IM小黑屋加入聊天室成功房间id=%@",roomId];
|
||||
} fail:^(int code, NSString *desc) {
|
||||
// 加入群组失败
|
||||
QXLOG(@"腾讯IM小黑屋加入聊天室失败-code%d-原因%@",code,desc);
|
||||
[QXLogger infoWithTag:@"房间日志" format:@"腾讯IM小黑屋加入聊天室失败-code%d-原因%@",code,desc];
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)quitGroupWithRoomId:(NSString *)roomId removeListener:(BOOL)removeListener{
|
||||
if (removeListener) {
|
||||
self.groupId = nil;
|
||||
@@ -75,6 +95,10 @@
|
||||
|
||||
}];
|
||||
}
|
||||
-(void)quitExGroup{
|
||||
self.exGroupId = nil;
|
||||
self.exRoomId = nil;
|
||||
}
|
||||
// 新成员加入
|
||||
-(void)onMemberEnter:(NSString *)groupID memberList:(NSArray<V2TIMGroupMemberInfo *> *)memberList{
|
||||
|
||||
@@ -103,7 +127,8 @@
|
||||
QXRoomMessage *msg = [QXRoomMessage yy_modelWithJSON:jsonStr];
|
||||
NSString *groupId = [NSString stringWithFormat:@"room%@",msg.RoomId];
|
||||
[QXLogger infoWithTag:@"推送日志" format:@"房间id=%@收到系统推送%@",msg.RoomId,jsonStr];
|
||||
if ([groupId isEqualToString:self.groupId]) {
|
||||
if ([groupId isEqualToString:self.groupId] || [groupId isEqualToString:self.exGroupId]) {
|
||||
BOOL isSuperRoom = [self.exGroupId isEqualToString:groupId];
|
||||
// 处理逻辑
|
||||
NSInteger meesageType = msg.MsgType.integerValue;
|
||||
switch (meesageType) {
|
||||
@@ -116,15 +141,23 @@
|
||||
QXRoomChatListModel *model = [QXRoomChatListModel yy_modelWithJSON:msg.Text];
|
||||
model.messageType = QXRoomChatMessageTypeSystem;
|
||||
NSString *jia_jia = [NSString stringWithFormat:@"%@",msg.Text[@"jia_jia"]];
|
||||
if (([jia_jia hasPrefix:@"http"] || [jia_jia hasPrefix:@"https"]) && ([jia_jia hasSuffix:@"svga"] || [jia_jia hasSuffix:@"mp4"])) {
|
||||
// QXGiftModel *md = [[QXGiftModel alloc] init];
|
||||
// md.play_image = jia_jia;
|
||||
[[QXGiftPlayerManager shareManager] displayChatEffectView:jia_jia];
|
||||
if ([self.exRoomId isExist] && [self.roomId isExist]) {
|
||||
/// 酒吧房小黑屋不管大房间的特效
|
||||
if ([groupId isEqualToString:self.groupId]){
|
||||
if (([jia_jia hasPrefix:@"http"] || [jia_jia hasPrefix:@"https"]) && ([jia_jia hasSuffix:@"svga"] || [jia_jia hasSuffix:@"mp4"])) {
|
||||
[[QXGiftPlayerManager shareManager] displayChatEffectView:jia_jia];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if (([jia_jia hasPrefix:@"http"] || [jia_jia hasPrefix:@"https"]) && ([jia_jia hasSuffix:@"svga"] || [jia_jia hasSuffix:@"mp4"])) {
|
||||
[[QXGiftPlayerManager shareManager] displayChatEffectView:jia_jia];
|
||||
}
|
||||
}
|
||||
if ([model.FromUserInfo.enter_image isExist]) {
|
||||
[[QXDrifNobilityJoinRoomView shareView] addNobilityUserModel:model];
|
||||
}
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
model.isSuperRoom = isSuperRoom;
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
if ([model.FromUserInfo.user_id isEqualToString:QXGlobal.shareGlobal.loginModel.user_id]) {
|
||||
@@ -146,11 +179,21 @@
|
||||
/// 收到礼物
|
||||
QXRoomChatListModel *model = [QXRoomChatListModel yy_modelWithJSON:msg.Text];
|
||||
model.messageType = QXRoomChatMessageTypeGift;
|
||||
if ([model.GiftInfo.play_image isExist]) {
|
||||
NSArray *arr = [model.GiftInfo.play_image componentsSeparatedByString:@","];
|
||||
[[QXGiftPlayerManager shareManager] displayFullEffectViewWithMorePlayImages:arr];
|
||||
if ([self.exRoomId isExist] && [self.roomId isExist]) {
|
||||
/// 酒吧房小黑屋不管大房间的特效
|
||||
if ([groupId isEqualToString:self.groupId]){
|
||||
NSArray *arr = [model.GiftInfo.play_image componentsSeparatedByString:@","];
|
||||
[[QXGiftPlayerManager shareManager] displayFullEffectViewWithMorePlayImages:arr];
|
||||
[[QXGiftDisplayManager sharedManager] receiveGift:model];
|
||||
}
|
||||
}else{
|
||||
if ([model.GiftInfo.play_image isExist]) {
|
||||
NSArray *arr = [model.GiftInfo.play_image componentsSeparatedByString:@","];
|
||||
[[QXGiftPlayerManager shareManager] displayFullEffectViewWithMorePlayImages:arr];
|
||||
}
|
||||
[[QXGiftDisplayManager sharedManager] receiveGift:model];
|
||||
}
|
||||
[[QXGiftDisplayManager sharedManager] receiveGift:model];
|
||||
|
||||
if (model.ToUserInfos.count>0) {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didRecieveGiftWithWithUserInfos:)]) {
|
||||
[self.delegate didRecieveGiftWithWithUserInfos:model.ToUserInfos];
|
||||
@@ -164,6 +207,7 @@
|
||||
return;
|
||||
}
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
model.isSuperRoom = isSuperRoom;
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
}
|
||||
@@ -184,12 +228,13 @@
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
if (!model.is_pk) {
|
||||
// 非pk房间的消息插入公屏
|
||||
model.isSuperRoom = isSuperRoom;
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
}
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didUpDownSeatWithUser:isUpSeat:pit_number:isPK:)]) {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didUpDownSeatWithUser:isUpSeat:pit_number:isPK:end_time:)]) {
|
||||
NSString *pit_number = [NSString stringWithFormat:@"%@",msg.Text[@"pit_number"]];
|
||||
[self.delegate didUpDownSeatWithUser:model.FromUserInfo isUpSeat:YES pit_number:pit_number.integerValue isPK:model.is_pk];
|
||||
[self.delegate didUpDownSeatWithUser:model.FromUserInfo isUpSeat:YES pit_number:pit_number.integerValue isPK:model.is_pk end_time:model.end_time];
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -200,12 +245,13 @@
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
if (!model.is_pk) {
|
||||
// 非pk房间的消息插入公屏
|
||||
model.isSuperRoom = isSuperRoom;
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
}
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didUpDownSeatWithUser:isUpSeat:pit_number:isPK:)]) {
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didUpDownSeatWithUser:isUpSeat:pit_number:isPK:end_time:)]) {
|
||||
NSString *pit_number = [NSString stringWithFormat:@"%@",msg.Text[@"pit_number"]];
|
||||
[self.delegate didUpDownSeatWithUser:model.FromUserInfo isUpSeat:NO pit_number:pit_number.integerValue isPK:model.is_pk];
|
||||
[self.delegate didUpDownSeatWithUser:model.FromUserInfo isUpSeat:NO pit_number:pit_number.integerValue isPK:model.is_pk end_time:model.end_time];
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -744,10 +790,54 @@
|
||||
NSString *jia_jia = [NSString stringWithFormat:@"%@",msg.Text[@"play_image"]];
|
||||
[[QXGiftPlayerManager shareManager] displayChatEffectView:jia_jia];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
model.isSuperRoom = isSuperRoom;
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case QXRoomMessageTypeSeductionEffect:{
|
||||
QXRoomChatListModel *model = [QXRoomChatListModel yy_modelWithJSON:msg.Text];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
model.isSuperRoom = isSuperRoom;
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(barRoomSeductionEffectWithModel:)]) {
|
||||
[self.delegate barRoomSeductionEffectWithModel:model];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case QXRoomMessageTypeJoinBarCabinRoom:{
|
||||
QXRoomChatListModel *model = [QXRoomChatListModel yy_modelWithJSON:msg.Text];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
model.isSuperRoom = isSuperRoom;
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
NSString *cabinRoomId = [NSString stringWithFormat:@"%@",msg.Text[@"room_id"]];
|
||||
NSString *user_id = [NSString stringWithFormat:@"%@",msg.Text[@"user_id"]];
|
||||
NSString *meet_user_id = [NSString stringWithFormat:@"%@",msg.Text[@"meet_user_id"]];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(barRoomJoinCabinRoomWithRoomId:user_id:meet_user_id:)]) {
|
||||
[self.delegate barRoomJoinCabinRoomWithRoomId:cabinRoomId user_id:user_id meet_user_id:meet_user_id];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QXRoomMessageTypeBarRoomHugPit:{
|
||||
NSString *user_id = [NSString stringWithFormat:@"%@",msg.Text[@"user_id"]];
|
||||
NSString *pit_number = [NSString stringWithFormat:@"%@",msg.Text[@"pit_number"]];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(barRoomHugPitWithUserId:pit_number:)]) {
|
||||
[self.delegate barRoomHugPitWithUserId:user_id pit_number:pit_number];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QXRoomMessageTypeBarRoomSetCustomGift:{
|
||||
NSString *user_id = [NSString stringWithFormat:@"%@",msg.Text[@"user_id"]];
|
||||
NSString *type = [NSString stringWithFormat:@"%@",msg.Text[@"type"]];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(barRoomSetCustomGiftWithUserId:had_custom_gift:)]) {
|
||||
[self.delegate barRoomSetCustomGiftWithUserId:user_id had_custom_gift:type.intValue==1];
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -871,12 +961,16 @@
|
||||
-(void)onRecvGroupCustomMessage:(NSString *)msgID groupID:(NSString *)groupID sender:(V2TIMGroupMemberInfo *)info customData:(NSData *)data{
|
||||
NSString *jsonStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
QXRoomMessage *msg = [QXRoomMessage yy_modelWithJSON:jsonStr];
|
||||
if ([groupID isEqualToString:self.groupId]) {
|
||||
NSString *groupId = [NSString stringWithFormat:@"room%@",msg.RoomId];
|
||||
[QXLogger infoWithTag:@"推送日志" format:@"房间id=%@收到系统推送%@",msg.RoomId,jsonStr];
|
||||
if ([groupId isEqualToString:self.groupId] || [groupId isEqualToString:self.exGroupId]) {
|
||||
BOOL isSuperRoom = [self.exGroupId isEqualToString:groupId];
|
||||
NSInteger meesageType = msg.MsgType.integerValue;
|
||||
if (meesageType == QXRoomMessageTypeText) {
|
||||
QXRoomChatListModel *model = [QXRoomChatListModel yy_modelWithJSON:msg.Text];
|
||||
model.messageType = QXRoomChatMessageTypeChat;
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
model.isSuperRoom = isSuperRoom;
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
}else if (meesageType == QXRoomMessageTypeClearMessage) {
|
||||
@@ -907,6 +1001,7 @@
|
||||
QXRoomChatListModel *model = [QXRoomChatListModel yy_modelWithJSON:msg.Text];
|
||||
model.messageType = QXRoomChatMessageTypeEmoji;
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
model.isSuperRoom = isSuperRoom;
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
}
|
||||
@@ -914,9 +1009,9 @@
|
||||
|
||||
}
|
||||
|
||||
-(void)sendChatMessage:(NSString *)message messageType:(QXRoomMessageType)messageType needInsertMessage:(BOOL)needInsertMessage{
|
||||
-(void)sendChatMessage:(NSString *)message messageType:(QXRoomMessageType)messageType needInsertMessage:(BOOL)needInsertMessage isSuperRoom:(BOOL)isSuperRoom{
|
||||
NSDictionary *dict = @{
|
||||
@"RoomId":self.roomId?self.roomId:@"",
|
||||
@"RoomId":isSuperRoom?self.exRoomId?:@"":self.roomId?:@"",
|
||||
@"MsgType":[NSNumber numberWithInteger:messageType],
|
||||
@"Text":@{
|
||||
@"FromUserInfo":@{
|
||||
@@ -945,22 +1040,23 @@
|
||||
model.FromUserInfo = userInfo;
|
||||
model.messageType = QXRoomChatMessageTypeChat;
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
model.isSuperRoom = isSuperRoom;
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
}
|
||||
NSString *jsonStr = [dict jsonStringEncoded];
|
||||
NSData *data =[jsonStr dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[[V2TIMManager sharedInstance] sendGroupCustomMessage:data to:self.groupId priority:V2TIM_PRIORITY_NORMAL succ:^{
|
||||
[[V2TIMManager sharedInstance] sendGroupCustomMessage:data to:isSuperRoom?self.exGroupId?:@"":self.groupId?:@"" priority:V2TIM_PRIORITY_NORMAL succ:^{
|
||||
QXLOG(@"发送自定义消息成功");
|
||||
} fail:^(int code, NSString * _Nullable desc) {
|
||||
QXLOG(@"发送自定义消息失败");
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
-(void)sendChatEmoji:(QXEmojiModel *)emoji{
|
||||
|
||||
|
||||
-(void)sendChatEmoji:(QXEmojiModel *)emoji isSuperRoom:(BOOL)isSuperRoom{
|
||||
NSDictionary *dict = @{
|
||||
@"RoomId":self.roomId?self.roomId:@"",
|
||||
@"RoomId":isSuperRoom?self.exRoomId?:@"":self.roomId?:@"",
|
||||
@"MsgType":[NSNumber numberWithInteger:QXRoomMessageTypeEmoji],
|
||||
@"Text":@{
|
||||
@"FromUserInfo":@{
|
||||
@@ -993,11 +1089,12 @@
|
||||
model.messageType = QXRoomChatMessageTypeEmoji;
|
||||
model.emoji = emoji;
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didInsertMessge:)]) {
|
||||
model.isSuperRoom = isSuperRoom;
|
||||
[self.delegate didInsertMessge:model];
|
||||
}
|
||||
NSString *jsonStr = [dict jsonStringEncoded];
|
||||
NSData *data =[jsonStr dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[[V2TIMManager sharedInstance] sendGroupCustomMessage:data to:self.groupId priority:V2TIM_PRIORITY_NORMAL succ:^{
|
||||
[[V2TIMManager sharedInstance] sendGroupCustomMessage:data to:isSuperRoom?self.exGroupId?:@"":self.groupId?:@"" priority:V2TIM_PRIORITY_NORMAL succ:^{
|
||||
QXLOG(@"发送自定义消息成功");
|
||||
} fail:^(int code, NSString * _Nullable desc) {
|
||||
QXLOG(@"发送自定义消息失败");
|
||||
|
||||
Reference in New Issue
Block a user