删除了发送自定义消息的helper

This commit is contained in:
fengshuo
2021-12-01 10:46:14 +08:00
committed by zu
parent c73c16f3fa
commit 6ec0c5b323
6 changed files with 43 additions and 113 deletions

View File

@@ -192,7 +192,6 @@
E884C36C2743951B00E1EBED /* GiftReceiveInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E884C36B2743951B00E1EBED /* GiftReceiveInfoModel.m */; }; E884C36C2743951B00E1EBED /* GiftReceiveInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E884C36B2743951B00E1EBED /* GiftReceiveInfoModel.m */; };
E884C36F2743AAC800E1EBED /* AttachmentModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E884C36E2743AAC800E1EBED /* AttachmentModel.m */; }; E884C36F2743AAC800E1EBED /* AttachmentModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E884C36E2743AAC800E1EBED /* AttachmentModel.m */; };
E884C3722743AEDE00E1EBED /* CustomAttachmentDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = E884C3712743AEDE00E1EBED /* CustomAttachmentDecoder.m */; }; E884C3722743AEDE00E1EBED /* CustomAttachmentDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = E884C3712743AEDE00E1EBED /* CustomAttachmentDecoder.m */; };
E884C37B2743B6E900E1EBED /* IMMessageHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E884C37A2743B6E900E1EBED /* IMMessageHelper.m */; };
E88B5CA526FB088600DA9178 /* XPMineTeenagerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */; }; E88B5CA526FB088600DA9178 /* XPMineTeenagerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */; };
E88B5CA826FB089C00DA9178 /* XPMineTeenagePwdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA726FB089C00DA9178 /* XPMineTeenagePwdViewController.m */; }; E88B5CA826FB089C00DA9178 /* XPMineTeenagePwdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA726FB089C00DA9178 /* XPMineTeenagePwdViewController.m */; };
E88B5CAD26FB16A800DA9178 /* XPMineTeenagerDesView.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CAC26FB16A800DA9178 /* XPMineTeenagerDesView.m */; }; E88B5CAD26FB16A800DA9178 /* XPMineTeenagerDesView.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CAC26FB16A800DA9178 /* XPMineTeenagerDesView.m */; };
@@ -671,8 +670,6 @@
E884C36E2743AAC800E1EBED /* AttachmentModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AttachmentModel.m; sourceTree = "<group>"; }; E884C36E2743AAC800E1EBED /* AttachmentModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AttachmentModel.m; sourceTree = "<group>"; };
E884C3702743AEDE00E1EBED /* CustomAttachmentDecoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CustomAttachmentDecoder.h; sourceTree = "<group>"; }; E884C3702743AEDE00E1EBED /* CustomAttachmentDecoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CustomAttachmentDecoder.h; sourceTree = "<group>"; };
E884C3712743AEDE00E1EBED /* CustomAttachmentDecoder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CustomAttachmentDecoder.m; sourceTree = "<group>"; }; E884C3712743AEDE00E1EBED /* CustomAttachmentDecoder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CustomAttachmentDecoder.m; sourceTree = "<group>"; };
E884C3792743B6E900E1EBED /* IMMessageHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IMMessageHelper.h; sourceTree = "<group>"; };
E884C37A2743B6E900E1EBED /* IMMessageHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = IMMessageHelper.m; sourceTree = "<group>"; };
E88B5CA326FB088600DA9178 /* XPMineTeenagerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagerViewController.h; sourceTree = "<group>"; }; E88B5CA326FB088600DA9178 /* XPMineTeenagerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagerViewController.h; sourceTree = "<group>"; };
E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineTeenagerViewController.m; sourceTree = "<group>"; }; E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineTeenagerViewController.m; sourceTree = "<group>"; };
E88B5CA626FB089C00DA9178 /* XPMineTeenagePwdViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagePwdViewController.h; sourceTree = "<group>"; }; E88B5CA626FB089C00DA9178 /* XPMineTeenagePwdViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagePwdViewController.h; sourceTree = "<group>"; };
@@ -1914,8 +1911,6 @@
children = ( children = (
E884C3702743AEDE00E1EBED /* CustomAttachmentDecoder.h */, E884C3702743AEDE00E1EBED /* CustomAttachmentDecoder.h */,
E884C3712743AEDE00E1EBED /* CustomAttachmentDecoder.m */, E884C3712743AEDE00E1EBED /* CustomAttachmentDecoder.m */,
E884C3792743B6E900E1EBED /* IMMessageHelper.h */,
E884C37A2743B6E900E1EBED /* IMMessageHelper.m */,
); );
path = Tool; path = Tool;
sourceTree = "<group>"; sourceTree = "<group>";
@@ -2825,7 +2820,6 @@
E88B5CC126FB407B00DA9178 /* XPMineUserInfoViewController.m in Sources */, E88B5CC126FB407B00DA9178 /* XPMineUserInfoViewController.m in Sources */,
E824545926F5E65900BE8163 /* XPMineVerifIdentityView.m in Sources */, E824545926F5E65900BE8163 /* XPMineVerifIdentityView.m in Sources */,
189DD74026E21C3F00AB55B1 /* YYUtility+App.m in Sources */, 189DD74026E21C3F00AB55B1 /* YYUtility+App.m in Sources */,
E884C37B2743B6E900E1EBED /* IMMessageHelper.m in Sources */,
189DD74526E21CCC00AB55B1 /* YYReachability.m in Sources */, 189DD74526E21CCC00AB55B1 /* YYReachability.m in Sources */,
E82109AD26F1C8A000FC3319 /* CountDownHelper.m in Sources */, E82109AD26F1C8A000FC3319 /* CountDownHelper.m in Sources */,
E8E70D8F26F2F5DB00F03460 /* XPMineMenuTableViewCell.m in Sources */, E8E70D8F26F2F5DB00F03460 /* XPMineMenuTableViewCell.m in Sources */,

View File

@@ -1,30 +0,0 @@
//
// IMMessageHelper.h
// xplan-ios
//
// Created by 冯硕 on 2021/11/16.
//
#import <Foundation/Foundation.h>
#import <NIMSDK/NIMSDK.h>
#import "AttachmentModel.h"
NS_ASSUME_NONNULL_BEGIN
///发送消息的工具类
@class UserInfoModel;
@interface IMMessageHelper : NSObject
/// 发送自定义消息
/// @param attachment 自定消息的内容
/// @param sessionId 回话ID
/// @param type 回话的类型
/// @pararm userInfo 当前的用户
+ (void)sendCustomMessage:(AttachmentModel *)attachment
sessionId:(NSString *)sessionId
type:(NIMSessionType)type
userInfo:(UserInfoModel *)userInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -1,63 +0,0 @@
//
// IMMessageHelper.m
// xplan-ios
//
// Created by on 2021/11/16.
//
#import "IMMessageHelper.h"
#import "UserInfoModel.h"
@implementation IMMessageHelper
///
/// @param attachment
/// @param sessionId ID
/// @param type
+ (void)sendCustomMessage:(AttachmentModel *)attachment
sessionId:(NSString *)sessionId
type:(NIMSessionType)type
userInfo:(UserInfoModel *)userInfo {
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachment;
message.messageObject = object;
//yidun
NIMAntiSpamOption *option = [NIMAntiSpamOption new];
option.yidunEnabled =NO;
message.antiSpamOption = option;
NIMMessageSetting *setting = [[NIMMessageSetting alloc]init];
setting.apnsEnabled = NO;
message.setting = setting;
if (type == NIMSessionTypeChatroom) {
message.remoteExt = [self makeMessageRemoteExt:userInfo];
}
//
NIMSession *session = [NIMSession session:sessionId type:type];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
}
///
+ (NSDictionary *)makeMessageRemoteExt:(UserInfoModel *)userInfo {
NSMutableDictionary * remoteExt = [NSMutableDictionary dictionary];
if (userInfo.erbanNo) {
[remoteExt setValue:[NSString stringWithFormat:@"%ld", userInfo.erbanNo] forKey:@"erbanNo"];
}
[remoteExt setValue:@(userInfo.defUser) forKey:@"defUser"];
[remoteExt setValue:@(userInfo.newUser) forKey:@"newUser"];
[remoteExt setValue:@(userInfo.hasPrettyErbanNo) forKey:@"hasPrettyErbanNo"];
[remoteExt setValue:userInfo.defUser == UserLevelType_Offical ? @(YES) : @(NO) forKey:@"official"];
if (userInfo.userLevelVo.charmUrl.length > 0) {
[remoteExt setValue:userInfo.userLevelVo.charmUrl forKey:@"charmUrl"];
}
if (userInfo.userLevelVo.experUrl.length > 0) {
[remoteExt setValue:userInfo.userLevelVo.experUrl forKey:@"experUrl"];
}
return remoteExt;
}
@end

View File

@@ -15,7 +15,6 @@
#import "TTPopup.h" #import "TTPopup.h"
#import "ThemeColor+SendGift.h" #import "ThemeColor+SendGift.h"
#import "XCHUDTool.h" #import "XCHUDTool.h"
#import "IMMessageHelper.h"
///Model ///Model
#import "GiftInfoModel.h" #import "GiftInfoModel.h"
#import "XPGiftCountModel.h" #import "XPGiftCountModel.h"
@@ -96,7 +95,6 @@
- (void)sendCustomMessage:(GiftReceiveInfoModel *)receiveModel oringinDic:(NSDictionary *)originDic { - (void)sendCustomMessage:(GiftReceiveInfoModel *)receiveModel oringinDic:(NSDictionary *)originDic {
AttachmentModel *attachement = [[AttachmentModel alloc] init]; AttachmentModel *attachement = [[AttachmentModel alloc] init];
NSDictionary * dict = originDic; NSDictionary * dict = originDic;
NSString *sessionID = [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].roomId];
UserInfoModel * userInfo = [self.delegate getUserInfo]; UserInfoModel * userInfo = [self.delegate getUserInfo];
if (receiveModel.roomSendGiftType == RoomSendGiftType_AllMic) { // if (receiveModel.roomSendGiftType == RoomSendGiftType_AllMic) { //
NSMutableDictionary *data = [NSMutableDictionary dictionary]; NSMutableDictionary *data = [NSMutableDictionary dictionary];
@@ -115,7 +113,7 @@
[data removeObjectForKey:@"luckyBagGifts"]; [data removeObjectForKey:@"luckyBagGifts"];
[data removeObjectForKey:@"targetUsers"]; [data removeObjectForKey:@"targetUsers"];
attachement.data = data; attachement.data = data;
[IMMessageHelper sendCustomMessage:attachement sessionId:sessionID type:NIMSessionTypeChatroom userInfo:userInfo]; [self sendCustomMessage:attachement];
}]; }];
} }
}else { // }else { //
@@ -123,7 +121,7 @@
attachement.second = Custom_Message_Sub_AllMicroSend; attachement.second = Custom_Message_Sub_AllMicroSend;
[data setObject:[dict valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"]; [data setObject:[dict valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
attachement.data = data; attachement.data = data;
[IMMessageHelper sendCustomMessage:attachement sessionId:sessionID type:NIMSessionTypeChatroom userInfo:userInfo]; [self sendCustomMessage:attachement];
} }
} else if (receiveModel.roomSendGiftType == RoomSendGiftType_MutableOnMic) { // } else if (receiveModel.roomSendGiftType == RoomSendGiftType_MutableOnMic) { //
NSMutableDictionary *data = [NSMutableDictionary dictionary]; NSMutableDictionary *data = [NSMutableDictionary dictionary];
@@ -143,14 +141,14 @@
[data removeObjectForKey:@"luckyBagGifts"]; [data removeObjectForKey:@"luckyBagGifts"];
[data removeObjectForKey:@"targetUsers"]; [data removeObjectForKey:@"targetUsers"];
attachement.data = data; attachement.data = data;
[IMMessageHelper sendCustomMessage:attachement sessionId:sessionID type:NIMSessionTypeChatroom userInfo:userInfo]; [self sendCustomMessage:attachement];
}]; }];
} }
}else { // }else { //
attachement.first = CustomMessageType_ALLMicroSend; attachement.first = CustomMessageType_ALLMicroSend;
attachement.second = Custom_Message_Sub_AllBatchSend; attachement.second = Custom_Message_Sub_AllBatchSend;
attachement.data = data; attachement.data = data;
[IMMessageHelper sendCustomMessage:attachement sessionId:sessionID type:NIMSessionTypeChatroom userInfo:userInfo]; [self sendCustomMessage:attachement];
} }
} else if (receiveModel.roomSendGiftType == RoomSendGiftType_ToOne) { // } else if (receiveModel.roomSendGiftType == RoomSendGiftType_ToOne) { //
NSMutableDictionary *data = [NSMutableDictionary dictionary]; NSMutableDictionary *data = [NSMutableDictionary dictionary];
@@ -169,7 +167,7 @@
[data removeObjectForKey:@"luckyBagGifts"]; [data removeObjectForKey:@"luckyBagGifts"];
[data removeObjectForKey:@"targetUsers"]; [data removeObjectForKey:@"targetUsers"];
attachement.data = data; attachement.data = data;
[IMMessageHelper sendCustomMessage:attachement sessionId:sessionID type:NIMSessionTypeChatroom userInfo:userInfo]; [self sendCustomMessage:attachement];
}]; }];
}else { // }else { //
attachement.first = CustomMessageType_Gift; attachement.first = CustomMessageType_Gift;
@@ -179,12 +177,23 @@
[data setObject:[targetUsers valueForKeyPath:@"nick"] forKey:@"targetNick"]; [data setObject:[targetUsers valueForKeyPath:@"nick"] forKey:@"targetNick"];
[data setObject:[targetUsers valueForKeyPath:@"avatar"] forKey:@"targetAvatar"]; [data setObject:[targetUsers valueForKeyPath:@"avatar"] forKey:@"targetAvatar"];
attachement.data = data; attachement.data = data;
[IMMessageHelper sendCustomMessage:attachement sessionId:sessionID type:NIMSessionTypeChatroom userInfo:userInfo]; [self sendCustomMessage:attachement];
} }
} }
} }
- (void)sendCustomMessage:(AttachmentModel *)attachment {
NSString *sessionID = [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].roomId];
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachment;
message.messageObject = object;
//
NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
}
#pragma mark - Deal Send Gift Data #pragma mark - Deal Send Gift Data
- (NSString *)dealSendGiftCount:(XPGiftCountModel *)model gift:(GiftInfoModel *)gift { - (NSString *)dealSendGiftCount:(XPGiftCountModel *)model gift:(GiftInfoModel *)gift {
NSString * count = @"1"; NSString * count = @"1";

View File

@@ -7,6 +7,7 @@
#import "RoomHeaderView.h" #import "RoomHeaderView.h"
///Third ///Third
#import <NIMSDK/NIMSDK.h>
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
#import <MarqueeLabel.h> #import <MarqueeLabel.h>
#import <YYText/YYLabel.h> #import <YYText/YYLabel.h>
@@ -21,7 +22,6 @@
#import "XPHtmlUrl.h" #import "XPHtmlUrl.h"
#import "ApiHost.h" #import "ApiHost.h"
#import "AccountInfoStorage.h" #import "AccountInfoStorage.h"
#import "IMMessageHelper.h"
#import "HttpRequestHelper.h" #import "HttpRequestHelper.h"
///Model ///Model
#import "RoomInfoModel.h" #import "RoomInfoModel.h"
@@ -33,7 +33,7 @@
#import "XPWebViewcontroller.h" #import "XPWebViewcontroller.h"
@interface RoomHeaderView ()<XCShareViewDelegate, BaseViewControllerProtocol> @interface RoomHeaderView ()<XCShareViewDelegate>
/// ///
@property (nonatomic,strong) UIButton *backButton; @property (nonatomic,strong) UIButton *backButton;
/// ///
@@ -236,7 +236,14 @@
[dic setValue:userDic forKey:@"data"]; [dic setValue:userDic forKey:@"data"];
attachMent.data = dic; attachMent.data = dic;
NSString *sessionID = [NSString stringWithFormat:@"%ld", [self.hostDelegate getRoomInfo].roomId]; NSString *sessionID = [NSString stringWithFormat:@"%ld", [self.hostDelegate getRoomInfo].roomId];
[IMMessageHelper sendCustomMessage:attachMent sessionId:sessionID type:NIMSessionTypeChatroom userInfo:userInfo];
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachMent;
message.messageObject = object;
//
NIMSession *session = [NIMSession session:sessionID type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
/// ///
[self saveShare:shareInfo]; [self saveShare:shareInfo];
} }

View File

@@ -11,7 +11,6 @@
///Tool ///Tool
#import "XPMacro.h" #import "XPMacro.h"
#import "ThemeColor+UserCard.h" #import "ThemeColor+UserCard.h"
#import "IMMessageHelper.h"
#import "TTPopup.h" #import "TTPopup.h"
#import "XPHtmlUrl.h" #import "XPHtmlUrl.h"
#import "AccountInfoStorage.h" #import "AccountInfoStorage.h"
@@ -323,7 +322,14 @@
attachment.second = second; attachment.second = second;
attachment.data = [notifyModel model2dictionary]; attachment.data = [notifyModel model2dictionary];
NSString * sessionId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; NSString * sessionId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
[IMMessageHelper sendCustomMessage:attachment sessionId:sessionId type:NIMSessionTypeChatroom userInfo:userInfo];
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachment;
message.messageObject = object;
//
NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
} }
@@ -515,7 +521,14 @@
attachement.first = CustomMessageType_Queue; attachement.first = CustomMessageType_Queue;
attachement.second = Custom_Message_Sub_Queue_Invite; attachement.second = Custom_Message_Sub_Queue_Invite;
attachement.data = dic; attachement.data = dic;
[IMMessageHelper sendCustomMessage:attachement sessionId:roomId type:NIMSessionTypeChatroom userInfo:self.targetUserInfo];
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachement;
message.messageObject = object;
//
NIMSession *session = [NIMSession session:roomId type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
} }
} }