房间内的云信接入

This commit is contained in:
linyudan
2023-12-14 15:38:53 -08:00
parent 9ea5d1bbaa
commit 7494f5a3ea
28 changed files with 975 additions and 132 deletions

View File

@@ -44,10 +44,21 @@
#import "DDMsgInputView.h"
#import "DDEmojiInputView.h"
/// Tool
#import "DDRoomRequest.h"
#import "DDClientConfig.h"
#import "TTPopup.h"
/// Model
#import "UserInfoModel.h"
#import "RoomInfoModel.h"
/// Third
#import <NIMSDK/NIMSDK.h>
static RoomViewController *roomVC = nil;
static dispatch_once_t onceToken;
@interface RoomViewController ()<AppMessageManagerDelegate, DDMInputViewDelegate,SVGAPlayerDelegate,UIGestureRecognizerDelegate>
@interface RoomViewController ()<AppMessageManagerDelegate, DDMInputViewDelegate,SVGAPlayerDelegate,UIGestureRecognizerDelegate,
NIMChatroomManagerDelegate, NIMChatManagerDelegate, NIMConversationManagerDelegate, NIMLoginManagerDelegate>
/***/
@property (nonatomic,strong) DDAnimateImageView *bgImageView;
/***/
@@ -108,9 +119,15 @@ static dispatch_once_t onceToken;
//
@property (nonatomic, assign) BOOL isHalfClick;
///
///
@property (nonatomic, strong) UserInfoModel *userInfo;
///
@property (nonatomic, strong) RoomInfoModel *roomInfo;
@end
@implementation RoomViewController
#pragma mark - Dealloc
- (void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[_svgaTool destroy];
@@ -127,7 +144,11 @@ static dispatch_once_t onceToken;
[_inRoomSvgaPlayer removeFromSuperview];
_inRoomSvgaPlayer = nil;
}
[self removeNoticationNIM];
}
#pragma mark - Public Method
+ (instancetype)shareVC{
dispatch_once(&onceToken, ^{
roomVC = [[RoomViewController alloc] init];
@@ -158,6 +179,129 @@ static dispatch_once_t onceToken;
vc.jubao_id = self.roomID;
[self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - Life Cycle
- (void)viewDidLoad {
[super viewDidLoad];
AppDelegate *delegate = (AppDelegate*)kAppDelegate;
delegate.inRoom = YES;
[[AppMessageManager shareManager].delegate addDelegate:self delegateQueue:dispatch_get_main_queue()];
[AppMessageManager shareManager].roomID = self.roomID;
[[DDMTool sharedTool] observationInform:self sel:@selector(messageUnreadNumber:) notificationName:[[DDMTool sharedTool]getinformType:(YVMessageNotice_MessageUnreadNumber)]];
//
[[AppMessageManager shareManager] sendJoinRoomMessage:self.roomID passWord:self.roomPassWord follow_user_id:[ToolsObject isBlankString:self.followUserModel.user_id]];
[DDRoomRequest DD_GetRoomUserInformationWithRoomUid:self.roomID success:^(RoomInfoModel * _Nonnull roomInfo, UserInfoModel * _Nonnull userInfo) {
userInfo.fromUid = self.followUserModel.user_id;
// userInfo.fromType = self.followUserModel.
userInfo.fromNick = self.followUserModel.nickname;
// roomInfo.hasAnimationEffect;
self.roomInfo = roomInfo;
self.userInfo = userInfo;
if (roomInfo.valid) {
[DDRoomRequest DD_EnterNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId] User:self.userInfo];
} else {
if ([self.roomID isEqualToString:[NSString stringWithFormat:@"%ld", userInfo.uid]]) {
if (roomInfo.roomId > 0) {
[DDRoomRequest DD_OpenRoomTitle:roomInfo.title type:roomInfo.type roomPwd:roomInfo.roomPwd roomDesc:roomInfo.roomDesc backPic:@"" mgId:@"" success:^(RoomInfoModel * _Nonnull roomInfo) {
[DDRoomRequest DD_EnterNIMRoom:[NSString stringWithFormat:@"%ld",roomInfo.roomId] User:self.userInfo];
} fail:^(NSError * _Nonnull error) {
}];
}
}
}
NSLog(@"roomInfo %@ ---- userInfo:%@", roomInfo, userInfo);
} fail:^(NSError * _Nonnull error) {
}];
[self creatView];
[self initBlock];
[self addNoticationNIM];
[self createPlayer];
//
// for (NSInteger i = 0; i<100; i++) {
// RoomGiftAirPlaneModel *airModel = [[RoomGiftAirPlaneModel alloc]init];
// airModel.user_name = @"1111";
// airModel.user_id = @"1";
// airModel.avatar = @"";
// airModel.giftName = @"1111";
// airModel.giftNum = 1;
// airModel.small_img = @"1";
// airModel.isBarrage = 3;
// [self showAirPlaneViewToModel:airModel];
// }
}
#pragma mark - NIMChatroomManagerDelegate
- (void)chatroomBeKicked:(NIMChatroomBeKickedResult *)result {
}
#pragma mark - NIMChatManagerDelegate
///
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
}
///
- (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error {
}
#pragma mark - NIMConversationManagerDelegate
- (void)didAddRecentSession:(NIMRecentSession *)recentSession
totalUnreadCount:(NSInteger)totalUnreadCount {
}
- (void)didUpdateRecentSession:(NIMRecentSession *)recentSession
totalUnreadCount:(NSInteger)totalUnreadCount {
}
- (void)didRemoveRecentSession:(NIMRecentSession *)recentSession
totalUnreadCount:(NSInteger)totalUnreadCount {
}
#pragma mark - NIMLoginManagerDelegate
- (void)onKickout:(NIMLoginKickoutResult *)result {
}
#pragma mark - Notication()
- (void)addNoticationNIM {
[[NIMSDK sharedSDK].chatroomManager addDelegate:self];
[[NIMSDK sharedSDK].chatManager addDelegate:self];
[[NIMSDK sharedSDK].loginManager addDelegate:self];
[[NIMSDK sharedSDK].conversationManager addDelegate:self];
}
- (void)removeNoticationNIM {
NSLog(@"房间销毁了");
[[NIMSDK sharedSDK].chatroomManager removeDelegate:self];
[[NIMSDK sharedSDK].chatManager removeDelegate:self];
[[NIMSDK sharedSDK].loginManager removeDelegate:self];
[[NIMSDK sharedSDK].conversationManager removeDelegate:self];
}
#pragma mark --
- (void)closeRoomClosrSmoll:(BOOL)closeSmoll{
WeakSelf(ws);
@@ -245,32 +389,7 @@ static dispatch_once_t onceToken;
}];
});
}
- (void)viewDidLoad {
[super viewDidLoad];
[self creatView];
[self initBlock];
AppDelegate *delegate = (AppDelegate*)kAppDelegate;
delegate.inRoom = YES;
[[AppMessageManager shareManager].delegate addDelegate:self delegateQueue:dispatch_get_main_queue()];
[AppMessageManager shareManager].roomID = self.roomID;
[[DDMTool sharedTool] observationInform:self sel:@selector(messageUnreadNumber:) notificationName:[[DDMTool sharedTool]getinformType:(YVMessageNotice_MessageUnreadNumber)]];
//
[[AppMessageManager shareManager] sendJoinRoomMessage:self.roomID passWord:self.roomPassWord follow_user_id:[ToolsObject isBlankString:self.followUserModel.user_id]];
[self createPlayer];
//
// for (NSInteger i = 0; i<100; i++) {
// RoomGiftAirPlaneModel *airModel = [[RoomGiftAirPlaneModel alloc]init];
// airModel.user_name = @"1111";
// airModel.user_id = @"1";
// airModel.avatar = @"";
// airModel.giftName = @"1111";
// airModel.giftNum = 1;
// airModel.small_img = @"1";
// airModel.isBarrage = 3;
// [self showAirPlaneViewToModel:airModel];
// }
}
- (void)creatView{
[self bgImageView];
[self infoView];
@@ -526,15 +645,15 @@ static dispatch_once_t onceToken;
}
///
- (void)reloadManageMicroUI{
if(self.roomInfoModel.room_info.open_type ==1){
// if(self.roomInfoModel.room_info.open_type ==1){
self.hostMicroView.microModel = self.roomInfoModel.adminMicModel;
self.hostMicroView.hidden = NO;
self.guestMicroView.hidden = YES;
}else{
self.hostMicroView.microModel = self.roomInfoModel.hostMicModel;
self.guestMicroView.hidden = YES;
self.hostMicroView.hidden = NO;
}
// self.hostMicroView.hidden = NO;
// self.guestMicroView.hidden = YES;
// }else{
// self.hostMicroView.microModel = self.roomInfoModel.hostMicModel;
// self.guestMicroView.hidden = YES;
// self.hostMicroView.hidden = NO;
// }
self.guestMicroView.microModel = self.roomInfoModel.honorGuestMicModel;
}
///
@@ -672,18 +791,36 @@ static dispatch_once_t onceToken;
- (void)tipBtnClick{
KRepeatClickTime(1);
[RoomPopTool popRoomTipToText:self.roomInfoModel.room_info.room_desc curentVC:self];
[RoomPopTool popRoomTipToText:self.roomInfo.roomDesc curentVC:self];
}
///
- (void)rankBtnClick{
// NSString *url = @"";
// if([DDClientConfig shareConfig].configInfo.h5Uris.count > 0){
// for (DDClientH5UserModel *h5Model in [DDClientConfig shareConfig].configInfo.h5Uris) {
// if([h5Model.code isEqualToString:@"roomRank"]){
// url = h5Model.uri;
// break;;
// }
// }
// }
//
//
// ///
// DDWebViewController *controller = [DDWebViewController webControlerWithUrlStr:[NSString stringWithFormat:@"%@/modules/room_rank/index.html",API_HOST_H5_URL] isShowNavBar:NO isHalf:YES data:@{@"roomUid":self.roomID}];
// [self.navigationController pushViewController:controller animated:normal];
KRepeatClickTime(1);
NSString * routing = [NSString stringWithFormat:@"%@/#/roomlist",KWebURL];
DDWebViewController *webVc = [DDWebViewController webControlerWithUrlStr:routing isShowNavBar:NO isHalf:NO data:@{@"room_id":self.roomID}];
NSString * routing = @"http://beta.api.nnbc123.cn/yinmeng/modules/roomRank/index.html?roomUid=200343";
// [NSString stringWithFormat:@"%@/yinmeng/modules/room_rank/index.html?roomUid=%@",@"http://beta.api.nnbc123.cn",self.roomID];
DDWebViewController *webVc = [DDWebViewController webControlerWithUrlStr:routing isShowNavBar:NO isHalf:YES data:@{@"room_id":self.roomID}];
WeakSelf(ws);
webVc.goUserInfoBlock = ^(NSString * _Nonnull userID) {
DDMyInformationViewController * infoVC = [[DDMyInformationViewController alloc] init];
infoVC.user_id = userID;
[ws.navigationController pushViewController:infoVC animated:YES];
};
// [self presentViewController:webVc animated:NO completion:nil];
// [TTPopup popupView:webVc style:TTPopupStyleActionSheet];
XPSemiModalConfiguration *config = [XPSemiModalConfiguration defaultConfiguration];
config.backgroundOpacity = 0.5;
config.enableBackgroundAnimation = NO;
@@ -2935,16 +3072,22 @@ static dispatch_once_t onceToken;
}
///
- (void)collectionRoomWithIsCollection:(BOOL)isCollection{
NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] init];
[dataDic setObject:self.roomID forKey:@"room_id"];
[dataDic setObject:isCollection ?@"1":@"0" forKey:@"is_collect"];
WeakSelf(ws);
[NetworkRequest requestPOST:@"/room/collect" parameters:dataDic block:^(BaseResponse * _Nonnull response) {
if(response.code ==200){
ws.infoView.collectionBtn.hidden = isCollection;
ws.roomInfoModel.is_collect =isCollection;
}
[DDRoomRequest DD_RoomCollectionType:isCollection ? 2 : 1 roomUid:self.roomID success:^{
ws.infoView.collectionBtn.hidden = isCollection;
// ws.roomInfoModel.is_collect =isCollection;
}];
// NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] init];
// [dataDic setObject:self.roomID forKey:@"room_id"];
// [dataDic setObject:isCollection ?@"1":@"0" forKey:@"is_collect"];
// WeakSelf(ws);
// [NetworkRequest requestPOST:@"/room/collect" parameters:dataDic block:^(BaseResponse * _Nonnull response) {
// if(response.code ==200){
// ws.infoView.collectionBtn.hidden = isCollection;
// ws.roomInfoModel.is_collect =isCollection;
// }
// }];
}
///
- (void)getEventList{
@@ -3347,7 +3490,7 @@ static dispatch_once_t onceToken;
if (!_hostMicroView) {
_hostMicroView = [[RoomMicroView alloc] init];
_hostMicroView.backgroundColor = [UIColor clearColor];
_hostMicroView.hidden = YES;
// _hostMicroView.hidden = YES;
[self.view addSubview:_hostMicroView];
[_hostMicroView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(KAdaptedWidth(100), KAdaptedHeight(107)));