修改了可以添加多个代理的

This commit is contained in:
fengshuo
2021-10-21 19:53:26 +08:00
committed by zu
parent 01a4a94cfa
commit cb1a3a391d
12 changed files with 361 additions and 12 deletions

View File

@@ -151,6 +151,13 @@
E874B88427215B0E003954B9 /* XPIMRoomMicQueueDelegate.h in Sources */ = {isa = PBXBuildFile; fileRef = E874B8822721590D003954B9 /* XPIMRoomMicQueueDelegate.h */; };
E874B88827215D39003954B9 /* MicroModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E874B88727215D39003954B9 /* MicroModel.m */; };
E874B88B27215EAF003954B9 /* MicroQueueItemModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E874B88A27215EAF003954B9 /* MicroQueueItemModel.m */; };
E874B88F27216FFE003954B9 /* XPIMChatRoomMemberImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = E874B88E27216FFE003954B9 /* XPIMChatRoomMemberImpl.m */; };
E874B8912721712B003954B9 /* XPIMChatRoomMemberInterface.h in Sources */ = {isa = PBXBuildFile; fileRef = E874B890272170A6003954B9 /* XPIMChatRoomMemberInterface.h */; };
E874B89527217DA6003954B9 /* XPIMChatRoomMessageImpl.m in Sources */ = {isa = PBXBuildFile; fileRef = E874B89427217DA6003954B9 /* XPIMChatRoomMessageImpl.m */; };
E874B89727218349003954B9 /* ZegoAudioRoom.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 184862CA27213FC7005FC5DC /* ZegoAudioRoom.framework */; };
E874B89827218349003954B9 /* ZegoAudioRoom.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 184862CA27213FC7005FC5DC /* ZegoAudioRoom.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
E874B89A27218AAF003954B9 /* XPIMChatRoomMessageDelegate.h in Sources */ = {isa = PBXBuildFile; fileRef = E874B89927218A9A003954B9 /* XPIMChatRoomMessageDelegate.h */; };
E874B89B27218ABC003954B9 /* XPIMChatRoomMessageInterface.h in Sources */ = {isa = PBXBuildFile; fileRef = E874B89627217DC3003954B9 /* XPIMChatRoomMessageInterface.h */; };
E88B5CA526FB088600DA9178 /* XPMineTeenagerViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA426FB088600DA9178 /* XPMineTeenagerViewController.m */; };
E88B5CA826FB089C00DA9178 /* XPMineTeenagePwdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CA726FB089C00DA9178 /* XPMineTeenagePwdViewController.m */; };
E88B5CAD26FB16A800DA9178 /* XPMineTeenagerDesView.m in Sources */ = {isa = PBXBuildFile; fileRef = E88B5CAC26FB16A800DA9178 /* XPMineTeenagerDesView.m */; };
@@ -518,6 +525,13 @@
E874B88727215D39003954B9 /* MicroModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MicroModel.m; sourceTree = "<group>"; };
E874B88927215EAF003954B9 /* MicroQueueItemModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MicroQueueItemModel.h; sourceTree = "<group>"; };
E874B88A27215EAF003954B9 /* MicroQueueItemModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MicroQueueItemModel.m; sourceTree = "<group>"; };
E874B88D27216FFE003954B9 /* XPIMChatRoomMemberImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMChatRoomMemberImpl.h; sourceTree = "<group>"; };
E874B88E27216FFE003954B9 /* XPIMChatRoomMemberImpl.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPIMChatRoomMemberImpl.m; sourceTree = "<group>"; };
E874B890272170A6003954B9 /* XPIMChatRoomMemberInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMChatRoomMemberInterface.h; sourceTree = "<group>"; };
E874B89327217DA6003954B9 /* XPIMChatRoomMessageImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMChatRoomMessageImpl.h; sourceTree = "<group>"; };
E874B89427217DA6003954B9 /* XPIMChatRoomMessageImpl.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPIMChatRoomMessageImpl.m; sourceTree = "<group>"; };
E874B89627217DC3003954B9 /* XPIMChatRoomMessageInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMChatRoomMessageInterface.h; sourceTree = "<group>"; };
E874B89927218A9A003954B9 /* XPIMChatRoomMessageDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPIMChatRoomMessageDelegate.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>"; };
E88B5CA626FB089C00DA9178 /* XPMineTeenagePwdViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineTeenagePwdViewController.h; sourceTree = "<group>"; };
@@ -1439,6 +1453,8 @@
E874B869272105C0003954B9 /* IM */ = {
isa = PBXGroup;
children = (
E874B89227217D64003954B9 /* RoomMessage */,
E874B88C27216FB6003954B9 /* ChatRoomMember */,
E874B87D272158B9003954B9 /* MicroQueue */,
E874B8752721436F003954B9 /* Room */,
E874B86A272105DD003954B9 /* XPIMManager.h */,
@@ -1481,6 +1497,27 @@
path = Model;
sourceTree = "<group>";
};
E874B88C27216FB6003954B9 /* ChatRoomMember */ = {
isa = PBXGroup;
children = (
E874B88D27216FFE003954B9 /* XPIMChatRoomMemberImpl.h */,
E874B88E27216FFE003954B9 /* XPIMChatRoomMemberImpl.m */,
E874B890272170A6003954B9 /* XPIMChatRoomMemberInterface.h */,
);
path = ChatRoomMember;
sourceTree = "<group>";
};
E874B89227217D64003954B9 /* RoomMessage */ = {
isa = PBXGroup;
children = (
E874B89327217DA6003954B9 /* XPIMChatRoomMessageImpl.h */,
E874B89427217DA6003954B9 /* XPIMChatRoomMessageImpl.m */,
E874B89627217DC3003954B9 /* XPIMChatRoomMessageInterface.h */,
E874B89927218A9A003954B9 /* XPIMChatRoomMessageDelegate.h */,
);
path = RoomMessage;
sourceTree = "<group>";
};
E88B5CA926FB15B900DA9178 /* Teenager */ = {
isa = PBXGroup;
children = (
@@ -2052,6 +2089,9 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
E874B89B27218ABC003954B9 /* XPIMChatRoomMessageInterface.h in Sources */,
E874B89A27218AAF003954B9 /* XPIMChatRoomMessageDelegate.h in Sources */,
E874B8912721712B003954B9 /* XPIMChatRoomMemberInterface.h in Sources */,
E874B88427215B0E003954B9 /* XPIMRoomMicQueueDelegate.h in Sources */,
E874B88327215B06003954B9 /* XPIMRoomMicQueueInterface.h in Sources */,
E874B87C27214888003954B9 /* XPIMRoomDelegate.h in Sources */,
@@ -2108,6 +2148,7 @@
E8E70D7A26F2F16600F03460 /* XPMinePresent.m in Sources */,
E8EEB8F226FC2050007C6EBA /* SDPhotoBrowser.m in Sources */,
E89DA67827009F16008483C1 /* NSObject+JSONString.m in Sources */,
E874B89527217DA6003954B9 /* XPIMChatRoomMessageImpl.m in Sources */,
E81C27AB26EF2D920031E639 /* ThirdUserInfo.m in Sources */,
E874B86C272105DD003954B9 /* XPIMManager.m in Sources */,
E81C279D26EEEC620031E639 /* XPConstant.m in Sources */,
@@ -2184,6 +2225,7 @@
E88F5EB0271ECEF000FF9B33 /* XPRoomViewController+RoomInfoContainerView.m in Sources */,
E86596542701A55500846EBD /* StatisticsServiceHelper.m in Sources */,
E8E70D8C26F2F5A500F03460 /* XPMineMatchCollectionViewCell.m in Sources */,
E874B88F27216FFE003954B9 /* XPIMChatRoomMemberImpl.m in Sources */,
186A534A26FC6ED900D67B2C /* TTActionSheetConfig.m in Sources */,
E81C279326EB394D0031E639 /* LoginForgetPasswordViewController.m in Sources */,
E81C278D26EAFAF60031E639 /* DESEncrypt.m in Sources */,

View File

@@ -0,0 +1,16 @@
//
// XPIMChatRoomMemberImpl.h
// xplan-ios
//
// Created by 冯硕 on 2021/10/21.
// 房间成员变化的类 在线列表 拉黑/移除成员 查询成员 设置/取消管理 踢出成员
#import <Foundation/Foundation.h>
#import "XPIMChatRoomMemberInterface.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPIMChatRoomMemberImpl : NSObject<XPIMChatRoomMemberInterface>
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,40 @@
//
// XPIMChatRoomMemberImpl.m
// xplan-ios
//
// Created by on 2021/10/21.
//
#import "XPIMChatRoomMemberImpl.h"
///Third
#import <ReactiveObjC/ReactiveObjC.h>
#import <NIMSDK/NIMSDK.h>
///Tool
#import "XPIMManager.h"
///Model
#import "RoomInfoModel.h"
@implementation XPIMChatRoomMemberImpl
#pragma mark - XPIMChatRoomMemberInterface
///Uid
- (RACSignal *)rac_queryChatRoomMember:(NSString *)uid {
return [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber> _Nonnull subscriber) {
RoomInfoModel * roomInfo =[XPIMManager shareManager].chatRoomManager.getCurrentRoomInfo;
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
request.userIds = @[uid];
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
if (error == nil) {
[subscriber sendNext:members.firstObject];
[subscriber sendCompleted];
}else {
[subscriber sendNext:nil];
}
}];
return nil;
}];
}
@end

View File

@@ -0,0 +1,19 @@
//
// XPIMChatRoomMemberInterface.h
// xplan-ios
//
// Created by 冯硕 on 2021/10/21.
//
#import <Foundation/Foundation.h>
#import <ReactiveObjC/ReactiveObjC.h>
NS_ASSUME_NONNULL_BEGIN
@protocol XPIMChatRoomMemberInterface <NSObject>
///通过Uid获取 成员
- (RACSignal *)rac_queryChatRoomMember:(NSString *)uid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -10,6 +10,7 @@
#import <NIMSDK/NIMSDK.h>
///Tool
#import "XPIMManager.h"
#import "AccountInfoStorage.h"
///Model
#import "MicroModel.h"
#import "MicroQueueItemModel.h"
@@ -21,10 +22,12 @@
#define MIC_COUNT(Type) [self roomTypecpORnormal:Type]
@interface XPIMRoomMicQueueImpl ()
///
@property (nonatomic,strong) id<XPIMRoomMicQueueDelegate> delegate;
/// < >
@property (nonatomic,strong) NSMutableDictionary<NSString *, MicroQueueItemModel *> *micQueue;
///
@property (nonatomic,assign) BOOL isLoadingMic;
///
@property (nonatomic,strong) NSMutableArray *delegateArray;
@end
@implementation XPIMRoomMicQueueImpl
@@ -38,6 +41,7 @@
}
}
///
- (void)configDefaultMicQueue {
RoomInfoModel * roomfInfo = [XPIMManager shareManager].chatRoomManager.getCurrentRoomInfo;
for (int i = 0 ; i < MIC_COUNT(roomfInfo.type); i++) {
@@ -51,6 +55,8 @@
}
}
#pragma mark - XPIMRoomMicQueueInterface
///
- (void)enterRoomRepairMicQueue:(NSDictionary *)micDictionary {
@@ -72,8 +78,11 @@
MicroQueueItemModel *sequence = [self.micQueue objectForKey:position];
sequence.userInfo = userInfo;
}
if ([self.delegate respondsToSelector:@selector(onGetRoomMicroQueueSuccess:)]) {
[self.delegate onGetRoomMicroQueueSuccess:self.micQueue];
for (id<XPIMRoomMicQueueDelegate> delegate in self.delegateArray) {
if ([delegate respondsToSelector:@selector(onGetRoomMicroQueueSuccess:)]) {
[delegate onGetRoomMicroQueueSuccess:self.micQueue];
}
}
} else {
NSLog(@"获取队列失败");
@@ -86,7 +95,27 @@
}
- (void)upMic:(NSString *)position {
if (self.isLoadingMic) {
#warning to do - toast
}
self.isLoadingMic = YES;
///
UserInfoModel *userInfo = [[self.micQueue objectForKey:position] userInfo];
if (userInfo) {
#warning to do -
} else {
NSString * uid = [[AccountInfoStorage instance] getUid];
[[[XPIMManager shareManager].chatRoomMemberManager rac_queryChatRoomMember:uid] subscribeNext:^(id _Nullable x) {
NIMChatroomMember * member = x;
if (member.type == NIMChatroomMemberTypeCreator || member.type == NIMTeamMemberTypeManager) {
} else {
}
}];
}
}
- (void)downMic:(NSString *)position {
@@ -95,11 +124,16 @@
///
- (void)addDelegate:(id<XPIMRoomMicQueueDelegate>)delegate {
self.delegate = delegate;
if (delegate) {
[self.delegateArray addObject:delegate];
}
}
///
- (void)removeDelegate:(id<XPIMRoomMicQueueDelegate>)delegate {
self.delegate = nil;
if (delegate && [self.delegateArray containsObject:delegate]) {
[self.delegateArray removeObject:delegate];
delegate = nil;
}
}
#pragma mark - Getters And Setters
@@ -109,5 +143,11 @@
}
return _micQueue;
}
- (NSMutableArray *)delegateArray {
if (!_delegateArray) {
_delegateArray = [NSMutableArray array];
}
return _delegateArray;
}
@end

View File

@@ -18,11 +18,10 @@
@interface XPImRoomImpl ()
///
@property (nonatomic,strong) id<XPIMRoomDelegate> delegate;
///
@property (nonatomic,strong) RoomInfoModel *roomInfo;
///
@property (nonatomic,strong) NSMutableArray *delegateArray;
@end
@@ -65,13 +64,25 @@
}
- (void)addDelegate:(id<XPIMRoomDelegate>)delegate {
self.delegate = delegate;
if (delegate) {
[self.delegateArray addObject:delegate];
}
}
- (void)removeDelegate:(id<XPIMRoomDelegate>)delegate {
self.delegate = nil;
if (delegate && [self.delegateArray containsObject:delegate]) {
[self.delegateArray removeObject:delegate];
delegate = nil;
}
}
#pragma mark - Getters And Setters
- (NSMutableArray *)delegateArray {
if (!_delegateArray) {
_delegateArray = [NSMutableArray array];
}
return _delegateArray;
}
@end

View File

@@ -0,0 +1,21 @@
//
// XPIMChatRoomMessageDelegate.h
// xplan-ios
//
// Created by 冯硕 on 2021/10/21.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class NIMMessage;
@protocol XPIMChatRoomMessageDelegate <NSObject>
///收到房间信息更细的消息
- (void)onReceiveRoomInfoUpdate:(NIMMessage *)message;
///收到队列消息变更的通知
- (void)onReceiveMicroQueueUpdate:(NIMMessage *)message;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,16 @@
//
// XPIMChatRoomMessageImpl.h
// xplan-ios
//
// Created by 冯硕 on 2021/10/21.
// 处理房间消息 收到房间消息的各种处理
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPIMChatRoomMessageImpl : NSObject
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,115 @@
//
// XPIMChatRoomMessageImpl.m
// xplan-ios
//
// Created by on 2021/10/21.
//
#import "XPIMChatRoomMessageImpl.h"
///Third
#import <NIMSDK/NIMSDK.h>
///Tool
#import "XPIMManager.h"
///Model
#import "RoomInfoModel.h"
///P
#import "XPIMChatRoomMessageDelegate.h"
@interface XPIMChatRoomMessageImpl ()<NIMChatManagerDelegate>
///
@property (nonatomic,strong) NSMutableArray *delegateArray;
@end
@implementation XPIMChatRoomMessageImpl
- (instancetype)init {
self = [super init];
if (self) {
[[NIMSDK sharedSDK].chatManager addDelegate:self];
}
return self;
}
- (void)dealloc {
[[NIMSDK sharedSDK].chatManager removeDelegate:self];
}
#pragma mark - Private Method
- (void)onReceiveMessageNotification:(NIMMessage *)message {
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
switch (content.eventType) {
case NIMChatroomEventTypeEnter:
///
break;
case NIMChatroomEventTypeExit:
{
/// 退线
}
break;
case NIMChatroomEventTypeAddBlack:
{
/// 线
}
break;
case NIMChatroomEventTypeRemoveBlack:
{
///
}
break;
case NIMChatroomEventTypeMemberUpdateInfo://ext
break;
case NIMChatroomEventTypeRemoveManager:
#warning to do
break;
case NIMChatroomEventTypeAddManager:
#warning to do
break;
case NIMChatroomEventTypeKicked:///
break;
case NIMChatroomEventTypeInfoUpdated://
break;
case NIMChatroomEventTypeQueueChange://
{
}
break;
default:
break;
}
}
#pragma mark - NIMChatManagerDelegate
///
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
for (NIMMessage * message in messages) {
///
if (message.session.sessionType == NIMSessionTypeChatroom && [message.session.sessionId isEqualToString:[NSString stringWithFormat:@"%ld", [XPIMManager shareManager].chatRoomManager.getCurrentRoomInfo.roomId]]) {
if (message.messageType == NIMMessageTypeText || message.messageType == NIMMessageTypeTip) {
#warning to do
} else if (message.messageType == NIMMessageTypeNotification) {
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
}else if (message.messageType == NIMMessageTypeCustom) {//
#warning to do
}
} else {
}
}
}
#pragma mark - Getters And Setters
- (NSMutableArray *)delegateArray {
if (!_delegateArray) {
_delegateArray = [NSMutableArray array];
}
return _delegateArray;
}
@end

View File

@@ -0,0 +1,16 @@
//
// XPIMChatRoomMessageInterface.h
// xplan-ios
//
// Created by 冯硕 on 2021/10/21.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol XPIMChatRoomMessageInterface <NSObject>
@end
NS_ASSUME_NONNULL_END

View File

@@ -8,6 +8,7 @@
#import <Foundation/Foundation.h>
#import "XPIMRoomInterface.h"
#import "XPIMRoomMicQueueInterface.h"
#import "XPIMChatRoomMemberInterface.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPIMManager : NSObject
@@ -16,6 +17,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic,strong, readonly) id<XPIMRoomInterface> chatRoomManager;
///麦序的管理类
@property (nonatomic,strong, readonly) id<XPIMRoomMicQueueInterface> microQueueManager;
///房间成员管理类
@property (nonatomic,strong, readonly) id<XPIMChatRoomMemberInterface> chatRoomMemberManager;
@end
NS_ASSUME_NONNULL_END

View File

@@ -8,11 +8,14 @@
#import "XPIMManager.h"
#import "XPImRoomImpl.h"
#import "XPIMRoomMicQueueImpl.h"
#import "XPIMChatRoomMemberImpl.h"
@interface XPIMManager ()
///
@property (nonatomic,strong) id<XPIMRoomInterface> chatRoomManager;
///
@property (nonatomic,strong) id<XPIMRoomMicQueueInterface> microQueueManager;
///
@property (nonatomic,strong) id<XPIMChatRoomMemberInterface> chatRoomMemberManager;
@end
@implementation XPIMManager
@@ -41,4 +44,11 @@
return _microQueueManager;
}
- (id<XPIMChatRoomMemberInterface>)chatRoomMemberManager {
if (!_chatRoomMemberManager) {
_chatRoomMemberManager = [[XPIMChatRoomMemberImpl alloc] init];
}
return _chatRoomMemberManager;
}
@end