119 lines
3.4 KiB
Objective-C
119 lines
3.4 KiB
Objective-C
//
|
|
// MsRoomMessageMainView.m
|
|
// YuMi
|
|
//
|
|
// Created by duoban on 2024/5/10.
|
|
//
|
|
#import "MsRoomMessageMainView.h"
|
|
#import "XPRoomMessageContainerView.h"
|
|
#import "ClientConfig.h"
|
|
#import "UserInfoModel.h"
|
|
#import <NIMSDK/NIMSDK.h>
|
|
#import "Api+Message.h"
|
|
#import "AttachmentModel.h"
|
|
#import "RoomInfoModel.h"
|
|
@interface MsRoomMessageMainView()<XPRoomMessageContainerViewDelegate>
|
|
|
|
@property(nonatomic,strong) XPRoomMessageContainerView *roomView;
|
|
|
|
///房间的代理
|
|
@property (nonatomic,weak) id<RoomHostDelegate> hostDelegate;
|
|
///是否是大的 只有在小游戏的时候有用
|
|
@property (nonatomic,assign) BOOL isLarge;
|
|
@end
|
|
|
|
@implementation MsRoomMessageMainView
|
|
|
|
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
|
self = [super init];
|
|
if (self) {
|
|
self.hostDelegate = delegate;
|
|
|
|
// TODO: 处理连击飘屏
|
|
|
|
[self installUI];
|
|
[self installConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
-(void)installUI{
|
|
[self addSubview:self.roomView];
|
|
}
|
|
-(void)installConstraints{
|
|
[self.roomView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.mas_equalTo(self);
|
|
}];
|
|
}
|
|
- (void)showUserCard:(NSInteger)uid{
|
|
[self.roomView showUserCard:uid];
|
|
}
|
|
|
|
#pragma mark - RoomGuestDelegate
|
|
- (void)handleNIMCustomMessage:(NIMMessage *)message {
|
|
UserInfoModel *infoModel = self.hostDelegate.getUserInfo;
|
|
NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[infoModel.partitionId]];
|
|
if(![message.session.sessionId isEqualToString:publicChatRoomId]){
|
|
[self.roomView handleNIMCustomMessage:message];
|
|
return;
|
|
}
|
|
}
|
|
|
|
- (void)handleNIMNotificationMessage:(NIMMessage *)message {
|
|
UserInfoModel *infoModel = self.hostDelegate.getUserInfo;
|
|
NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[infoModel.partitionId]];
|
|
if(![message.session.sessionId isEqualToString:publicChatRoomId]){
|
|
[self.roomView handleNIMNotificationMessage:message];
|
|
return;
|
|
}
|
|
}
|
|
|
|
- (void)handleNIMTextMessage:(NIMMessage *)message {
|
|
UserInfoModel *infoModel = self.hostDelegate.getUserInfo;
|
|
NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[infoModel.partitionId]];
|
|
if(![message.session.sessionId isEqualToString:publicChatRoomId]){
|
|
[self.roomView handleNIMTextMessage:message];
|
|
return;
|
|
}
|
|
}
|
|
|
|
- (void)handleNIMImageMessage:(NIMMessage *)message {
|
|
}
|
|
|
|
|
|
- (void)onRoomMiniEntered {
|
|
[self.roomView onRoomMiniEntered];
|
|
}
|
|
|
|
- (void)onRoomEntered {
|
|
[self.roomView onRoomEntered];
|
|
}
|
|
|
|
- (void)onRoomUpdate {
|
|
[self.roomView onRoomUpdate];
|
|
}
|
|
#pragma mark - XPRoomMessageContainerViewDelegate
|
|
- (void)xPRoomMessageContainerViewlDidTapEmpty:(XPRoomMessageContainerView *)view{
|
|
if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) {
|
|
self.isLarge = !self.isLarge;
|
|
CGFloat height = self.isLarge ? 200 : (iPhoneXSeries ? 100 : 80);
|
|
[self mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(height);
|
|
}];
|
|
}
|
|
}
|
|
|
|
#pragma mark - 懒加载
|
|
- (NSInteger)type{
|
|
return 0;
|
|
}
|
|
|
|
- (XPRoomMessageContainerView *)roomView{
|
|
if(!_roomView){
|
|
_roomView = [[XPRoomMessageContainerView alloc] initWithDelegate:self.hostDelegate];
|
|
_roomView.delegate = self;
|
|
}
|
|
return _roomView;
|
|
}
|
|
|
|
@end
|