// // MOTtmEntiry.m // MiMoLive // // Created by SuperC on 2023/11/21. // #import "MORtmEntity.h" #import "MOWishStatusList.h" @implementation MORtmFanBean @end @implementation MORtmVipBean @end @implementation MORtmFamilyBean @end @implementation MORtmHeaddress @end @implementation MORtmDressing @end @implementation MORtmUser + (NSDictionary *)modelContainerPropertyGenericClass { // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别 return @{@"vip":[MORtmVipBean class], @"fans":[MORtmFanBean class], @"family":[MORtmFamilyBean class], @"headdress":[MORtmHeaddress class], @"dressing":[MORtmDressing class]}; } @end @implementation MORtmGiftRebate + (NSDictionary *)modelContainerPropertyGenericClass { // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别 return @{@"user":[MORtmUser class]}; } @end @implementation MORtmLiveRoomViewer @end @implementation MORedEnvelopeObject @end @implementation MORtmRoomResolution @end @implementation MORtmUserDialogItem @end @implementation MORtmUserDialog + (NSDictionary *)modelContainerPropertyGenericClass { // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别 return @{@"iconItems":[MORtmUserDialogItem class]}; } @end @implementation MORtmFlexActivityPiggy @end @implementation MORtmWishList @end @implementation MORTMLinkMic + (NSDictionary *)modelContainerPropertyGenericClass { // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别 return @{@"user":[MORtmUser class]}; } @end @implementation MORtmFansClub @end @implementation MORtmOpenVipNotice @end @implementation MORtmUserLevelUpgrade @end @implementation MORtmFastGive @end @implementation MORtmFollowGive @end @implementation MORtmRoomDesireDone + (NSDictionary *)modelContainerPropertyGenericClass { // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别 return @{@"sender":[MORtmUser class]}; } @end @implementation MORtmBlindboxGift @end @implementation MORtmBlindboxDrawResult + (NSDictionary *)modelContainerPropertyGenericClass { return @{@"list": [MORtmBlindboxGift class]}; } @end @implementation MORtmGiftReturnForMultiple + (NSDictionary *)modelContainerPropertyGenericClass { return @{@"user":[MORtmUser class]}; } @end @implementation MORtmTranslate @end @implementation MORtmJosnEntity + (NSDictionary *)modelContainerPropertyGenericClass { // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别 return @{@"giftRebate":[MORtmGiftRebate class], @"l":[MORtmLiveRoomViewer class], @"linkMics":[MORTMLinkMic class], @"roomUser":[MORtmUser class], @"resolution":[MORtmRoomResolution class], @"activityPiggy":[MORtmFlexActivityPiggy class], @"fansClub":[MORtmFansClub class], @"openVipNotice":[MORtmOpenVipNotice class], @"rtmUserDialog":[MORtmUserDialog class], @"roomDesires":[MORoomDesire class], @"fastGive": [MORtmFastGive class], @"followGive": [MORtmFollowGive class], @"translateArr":[MORtmTranslate class], @"desireDone":[MORtmRoomDesireDone class], @"blindboxDrawResult":[MORtmBlindboxDrawResult class], @"dressing":[MORtmDressing class], @"pkLinkInvite":[MORtmLivePKLinkInvite class], @"pkV2Status":[MORtmPkV2Status class], @"pkV2StatusExpand":[MORtmPkV2StatusExpand class], @"returnForMultiple":[MORtmGiftReturnForMultiple class], @"rtmToast": [MORtmToast class], }; } @end @implementation MORtmEntity + (NSDictionary *)modelContainerPropertyGenericClass { // value使用[YYEatModel class]或YYEatModel.class或@"YYEatModel"没有区别 return @{@"user":[MORtmUser class]}; } - (id)copyWithZone:(NSZone *)zone { MORtmEntity *copy = [[MORtmEntity alloc] init]; if (copy) { copy.type = self.type; copy.data = self.data; copy.roomId = self.roomId; } return copy; } + (MORtmEntity *)prepareRealObjectWith:(MORtmEntity *)entity{ if(entity.type == MORtmChat || entity.type == MORtmEnter || entity.type == MORtmExit || entity.type == RoomClose || entity.type == MORtmLink || entity.type == PeerPK || entity.type == MORtmGift || entity.type == SystemOrder || entity.type == MOPKStatus || entity.type == MORtmChatSilence || entity.type == MORtmKick || entity.type == MORtmChatManage || entity.type == MORtmGiftEndNum || entity.type == MORtmRoomTip || entity.type == MORoomCleanRtmTip || entity.type == MOLikeComboTip || entity.type == SystemLiveUpdate || entity.type == MOChangeRoomType || entity.type == MORoomTipTwo || entity.type == MORoomVoiceTranslate){ MORtmJosnEntity *josnData = [MORtmJosnEntity modelWithJSON:entity.data]; josnData.changeSettingInfo = [MOSettingInfo modelObjectWithDictionary:josnData.multipleChange]; entity.data = josnData; return entity; } else if (entity.type == MOWishListTip){ NSArray *wishListArr = [NSArray modelArrayWithClass:[MORtmWishList class] json:entity.data]; entity.data = wishListArr; return entity; } else if (entity.type == MORtmMicApply || entity.type == MORtmMicAuditPass || entity.type == MORtmMicAuditRefuse){ MORtmJosnEntity *josnData = [MORtmJosnEntity modelWithJSON:entity.data]; entity.data = josnData; return entity; } return entity; } + (MORtmEntity *)prepareRtmTextMessageWithType:(MORtmContentType )type AndText:(NSString *)text And:(BOOL)danMu AndRoomId:(NSString *)roomId{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.content = text ? text : @""; jsonEntity.danmu = danMu; MORtmEntity *entity = [MORtmEntity new]; entity.type = type; entity.roomId = roomId ? roomId : @""; entity.data = jsonEntity; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } //创建一条艾特的文本 + (MORtmEntity *)prepareRtmTextMessageWithType:(MORtmContentType )type AndText:(NSString *)text And:(BOOL)danMu AndRoomId:(NSString *)roomId AndAtDict:(NSDictionary *)dict{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.content = text ? text : @""; jsonEntity.danmu = danMu; if(dict){ NSArray *allkeyArr = [dict allKeys]; if(allkeyArr.count > 0){ NSMutableArray *userIdArr = [NSMutableArray array]; for (NSString *key in allkeyArr) { [userIdArr addObject:dict[key]]; } if(userIdArr.count == allkeyArr.count){ NSString *atlist = [userIdArr componentsJoinedByString:@","]; NSString *atNameList = [allkeyArr componentsJoinedByString:@","]; jsonEntity.atList = atlist; jsonEntity.atNameList = atNameList; } } } MORtmEntity *entity = [MORtmEntity new]; entity.type = type; entity.roomId = roomId ? roomId : @""; entity.data = jsonEntity; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmUser *)prepareBaseUser{ MORtmUser *userInfo = [MORtmUser new]; userInfo.userId = GetUserId ? GetUserId : @""; userInfo.username = GetNickName ? GetNickName : @""; userInfo.avatar = GetAvatar ? GetAvatar : @""; userInfo.agoraId = GetAgoraId ? GetAgoraId : 0; userInfo.bubble = GetUserBubbleCode ? GetUserBubbleCode : 0; userInfo.headress = @"";//使用了新字段headRes userInfo.level = GetUserLevel ? GetUserLevel : 1; userInfo.rides = GetUserEnterBar ? GetUserEnterBar : 0; MORtmDressing *dressing = [MORtmDressing new]; dressing.bubble = GetUserBubbleCode ? GetUserBubbleCode : 0; dressing.entryBar = GetUserEnterBar ? GetUserEnterBar : 0; dressing.cardFrame = GetUserCardFrameCode ? GetUserCardFrameCode : 0; dressing.enterFloating = GetUserEnterFloatingCode ? GetUserEnterFloatingCode : 0; dressing.rewardBanner = GetUserRewardBannerCode ? GetUserRewardBannerCode : 0; dressing.linkMicFrame = GetUserLinkMicFrameCode ? GetUserLinkMicFrameCode : 0; dressing.liveBarrage = GetUserLiveBarrageCode ? GetUserLiveBarrageCode : 0; BOOL isMysterious = GetIsMysterious; if(isMysterious){ //神秘人 userInfo.username = @"Mystery Man"; userInfo.bubble = 0; userInfo.headress = @"";//使用了新字段headRes userInfo.level = 1; userInfo.rides = 0; dressing.bubble = 0; dressing.entryBar = 0; dressing.cardFrame = 0; dressing.enterFloating = 0; dressing.rewardBanner = 0; dressing.linkMicFrame = 0; dressing.liveBarrage = 0; if([MOSvgaSourceManage shareManager].theManAvatarUrl.length > 0){ userInfo.avatar = [MOSvgaSourceManage shareManager].theManAvatarUrl; } else{ userInfo.avatar = @""; } } userInfo.dressing = dressing;//装饰类赋值 //vip MORtmVipBean *vipInfo = [MORtmVipBean new]; NSInteger vipType = GetUserVipType ? GetUserVipType : 0; if(vipType != 0){ NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970] * 1000; NSInteger vipExpirTime = GetUserVipExpirTime ? GetUserVipExpirTime : 0; if(currentTime > vipExpirTime){ vipType = 0; } vipInfo.type = vipType; if(isMysterious){ vipInfo.type = 0; } userInfo.vip = vipInfo; } //粉丝团 MORtmFanBean *fanInfo = [MORtmFanBean new]; MOFanClubData *fanClubData = [MOSvgaSourceManage shareManager].myDataInfo.fanClubData; if(fanClubData.id.length > 0){ fanInfo.level = fanClubData.level; fanInfo.name = fanClubData.nameplate; if(isMysterious){ fanInfo.level = 0; fanInfo.name = @""; } userInfo.fans = fanInfo; } //勋章Code数组 NSArray *medalArr = [MOSvgaSourceManage shareManager].myDataInfo.userProfile.medalList; if(medalArr.count > 0){ NSMutableArray *medalMuArr = [NSMutableArray array]; for (MOMedalResources *object in medalArr) { NSInteger codeNum = (NSInteger)object.code; [medalMuArr addObject:@(codeNum)]; } if(isMysterious){ userInfo.medalCodeList = [NSMutableArray array]; } else{ userInfo.medalCodeList = [medalMuArr copy]; } } //MORtmHeaddress 头像对象 MORtmHeaddress *headdress = [MORtmHeaddress new]; headdress.type = GetUserHeaddressType ? GetUserHeaddressType : 0; headdress.res = GetUserHeaddress ? GetUserHeaddress : @""; if(isMysterious){ headdress.type = 0; headdress.res = @""; } userInfo.headressObject = headdress; return userInfo; } + (MORtmEntity *)prepareRtmApplyLianMaiMessageWithType:(MORtmContentType )type AndLinkMicType:(NSInteger)linkMicType AndRoomId:(NSString *)roomId{ //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断) MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.type = linkMicType ? linkMicType : 1; jsonEntity.status = 0; jsonEntity.roomId = roomId ? roomId : @""; MORtmEntity *entity = [MORtmEntity new]; entity.type = MORtmLink; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmEntity *)prepareRtmManageLianMaiMessageWithType:(MORtmContentType )type AndLinkMicType:(NSInteger)linkMicType AndStatus:(NSInteger)status AndAgoraId:(NSInteger)agoraId AndRoomId:(NSString *)roomId { //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断) //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断 5:上麦) 6, 主播邀请 7, 多人邀请- 用户同意 8主播音频变化 9: 用户自动上麦广播 10: 用户拒绝主播邀请 MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.type = linkMicType ? linkMicType : 1; jsonEntity.status = status; jsonEntity.agoraId = agoraId; jsonEntity.roomId = roomId ? roomId : @""; MORtmEntity *entity = [MORtmEntity new]; entity.type = type; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmEntity *)prepareRtmManageAgreeLianMaiMessageAndLinkMicType:(NSInteger)linkMicType AndStatus:(NSInteger)status AndAgoraId:(NSInteger)agoraId AndUserId:(NSString *)userId AndUserName:(NSString *)userName AndAvatar:(NSString *)avatar AndRoomId:(NSString *)roomId AndVipType:(NSInteger)vipType{ //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断) //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断 5:上麦) 6, 主播邀请 7, 多人邀请- 用户同意 8主播音频变化 9: 用户自动上麦广播 10: 用户拒绝主播邀请 MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.type = linkMicType ? linkMicType : 1; jsonEntity.status = status; jsonEntity.agoraId = agoraId; jsonEntity.userId = userId ? userId : @""; jsonEntity.userName = userName ? userName : @""; jsonEntity.avatar = avatar ? avatar : @""; jsonEntity.roomId = roomId ? roomId : @""; jsonEntity.vipType = vipType ? vipType : 0; MORtmEntity *entity = [MORtmEntity new]; entity.type = MORtmLink; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmEntity *)prepareRtmManageAgreeLianMaiMessageAndLinkMicType:(NSInteger)linkMicType AndStatus:(NSInteger)status AndRoomId:(NSString *)roomId AndMOLinkMic:(MOLinkMic *)linkMic AndSeatNum:(NSInteger)seatNum{ //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断) 5:上麦) 6, 主播邀请 7, 多人邀请- 用户同意 //状态 0:待审核 1:取消(观众) 2:同意(主播&管理员) 3:拒绝(主播&管理员) 4:挂断 5:上麦) 6, 主播邀请 7, 多人邀请- 用户同意 8主播音频变化 9: 用户自动上麦广播 10: 用户拒绝主播邀请 MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.type = linkMicType ? linkMicType : 1; jsonEntity.status = status; jsonEntity.agoraId = linkMic.profile.agoraId ? linkMic.profile.agoraId : 0; jsonEntity.userId = linkMic.profile.id ? linkMic.profile.id : @""; jsonEntity.userName = linkMic.profile.nickname ? linkMic.profile.nickname : @""; jsonEntity.avatar = linkMic.profile.avatar ? linkMic.profile.avatar : @""; jsonEntity.vipType = linkMic.profile.vipType ? linkMic.profile.vipType : 0; jsonEntity.roomId = roomId ? roomId : @""; jsonEntity.seatNum = seatNum ? seatNum : 0; jsonEntity.video1 = linkMic.video1; jsonEntity.video2 = linkMic.video2; jsonEntity.audio1 = linkMic.audio1; jsonEntity.audio2 = linkMic.audio2; jsonEntity.admin = linkMic.admin; NSDictionary *dressing = [linkMic.dressing modelToJSONObject]; jsonEntity.dressing = [MORtmDressing modelWithJSON:dressing]; if(status == 6){ jsonEntity.invite = linkMic.invite ? linkMic.invite : @""; jsonEntity.camera = linkMic.camera; } MORtmEntity *entity = [MORtmEntity new]; entity.type = MORtmLink; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmEntity *)prepareRtmActiveLianMaiMessageWithType:(MORtmContentType)type AndLinkMicType:(NSInteger)linkMicType AndRoomId:(NSString *)roomId{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.type = linkMicType ? linkMicType : 1; jsonEntity.roomId = roomId ? roomId : @""; NSInteger agoraId = GetAgoraId; jsonEntity.agoraId = agoraId ? agoraId : 0; MORtmEntity *entity = [MORtmEntity new]; entity.type = type; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmEntity *)prepareRtmPeerPkMessageWithStatus:(NSInteger)status PkSecretStr:(NSString *)pkSecretStr AndRoomId:(NSString *)roomId{ //状态, 0:待处理 1:取消 2:同意 3:拒绝 4:投降或退出 MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.status = status; jsonEntity.pkSecret = pkSecretStr; MORtmEntity *entity = [MORtmEntity new]; entity.type = PeerPK; entity.roomId = roomId ? roomId : @""; entity.data = jsonEntity; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmEntity *)prepareRtmPeerPkQuitMessageWith:(BOOL)isSurrender AndRoomId:(NSString *)roomId{ MORtmEntity *entity = [MORtmEntity new]; entity.type = PeerPKQuit; entity.data = @(isSurrender); MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; entity.roomId = roomId ? roomId : @""; return entity; } //根据消息类型枚举 创建一条对应Rtm消息 + (MORtmEntity *)prepareRtmMessageWithType:(MORtmContentType )type AndRoomId:(NSString *)roomId{ MORtmEntity *entity = [MORtmEntity new]; entity.type = type; entity.data = nil; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; entity.roomId = roomId ? roomId : @""; return entity; } + (MORtmEntity *)prepareRtmMessageWithEnterWith:(MOLiveDetail *)liveDetail{ MORtmEntity *entity = [MORtmEntity new]; entity.type = MORtmEnter; entity.roomId = liveDetail.currentRoom.id ? liveDetail.currentRoom.id : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; userInfo.enterBarPlayType = liveDetail.enterBarPlayType ? liveDetail.enterBarPlayType : 0; userInfo.enterFloatingSkinType = liveDetail.enterFloatingSkinType ? liveDetail.enterFloatingSkinType : 0; userInfo.enterFloatingAvatar = liveDetail.enterFloatingAvatar; entity.user = userInfo; return entity; } //准备一条 礼物 Rtm + (MORtmEntity *)prepareRtmGiftMessageWithCode:(NSInteger)code NameStr:(NSString *)nameStr Count:(NSInteger)count AndRoomId:(NSString *)roomId{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.code = code ? code : 1; jsonEntity.name = nameStr; jsonEntity.count = count ? count : 1; MORtmEntity *entity = [MORtmEntity new]; entity.type = MORtmGift; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } //准备一条 礼物 Rtm + (MORtmEntity *)prepareRtmGiftMessageWith:(MOGiftInfo *)giftInfo AndRoomId:(NSString *)roomId{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.code = giftInfo.giftCode ? giftInfo.giftCode : 1; jsonEntity.name = giftInfo.giftName; jsonEntity.count = giftInfo.num ? giftInfo.num : 1; jsonEntity.rebateMultiple = giftInfo.rebateMultiple ? giftInfo.rebateMultiple : 0; jsonEntity.rebateDiamond = giftInfo.rebateDiamond ? giftInfo.rebateDiamond : 0; jsonEntity.multipleUserList = (giftInfo.multipleUserList.count > 0) ? ([giftInfo.multipleUserList copy]) : nil; jsonEntity.priceDiamond = giftInfo.diamond ? giftInfo.diamond : 0; jsonEntity.hitDiamond = giftInfo.hitDiamond ? giftInfo.hitDiamond : 0; jsonEntity.antiDrillCritGift = giftInfo.antiDrillCritGift; if(giftInfo.selectSkin.id.length > 0){ jsonEntity.code = giftInfo.selectSkin.code ? giftInfo.selectSkin.code : 1; jsonEntity.name = giftInfo.selectSkin.name ? giftInfo.selectSkin.name : @""; } MORtmEntity *entity = [MORtmEntity new]; entity.type = MORtmGift; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } //准备一条 礼物数量 Rtm + (MORtmEntity *)prepareRtmGiftEndNumMessageWith:(MOGiftInfo *)giftInfo AndRoomId:(NSString *)roomId{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.code = giftInfo.giftCode ? giftInfo.giftCode : 1; jsonEntity.name = giftInfo.giftName; jsonEntity.count = giftInfo.num ? giftInfo.num : 1; jsonEntity.rebateMultiple = giftInfo.rebateMultiple ? giftInfo.rebateMultiple : 0; jsonEntity.rebateDiamond = giftInfo.rebateDiamond ? giftInfo.rebateDiamond : 0; jsonEntity.multipleUserList = (giftInfo.multipleUserList.count > 0) ? ([giftInfo.multipleUserList copy]) : nil; jsonEntity.effectType = giftInfo.effectType ? giftInfo.effectType : 0; MORtmEntity *entity = [MORtmEntity new]; entity.type = MORtmGiftEndNum; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } /// 准备一条PK 房间状态信息 /// - Parameters: /// - pkModel: PK状态对象 /// - status: PK状态 0:就绪 1:PK中 2:惩罚 3:结束 /// - quitStatus: 中途结束信息 1:对方退出 2:对方投降 3:我方退出 4:我方投降, 5:正常结束 0:单纯状态信息更新 + (MORtmEntity *)prepareRtmAboutPkStatusWith:(MOLiveList *)pkModel AndStatus:(NSInteger)status AndQuitStatus:(NSInteger)quitStatus AndRoomId:(NSString *)roomId{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.status = status ? status : 0; jsonEntity.selfScore = pkModel.weScore ? pkModel.weScore : 0; jsonEntity.oppScore = pkModel.oppScore ? pkModel.oppScore : 0; jsonEntity.quitInfo = quitStatus ? quitStatus : 0; MORtmEntity *entity = [MORtmEntity new]; entity.type = MOPKStatus; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmEntity *)preparePkRtmWith:(MOLinePKViewModel *)pkViewModel AndStatus:(NSInteger)status AndQuitStatus:(NSInteger)quitStatus AndRoomId:(NSString *)roomId{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.status = status ? status : 0; jsonEntity.selfScore = pkViewModel.curOwnerCampInfo.pkValue ?: 0; jsonEntity.oppScore = pkViewModel.curPeerCampInfo.pkValue ?: 0; jsonEntity.quitInfo = quitStatus ? quitStatus : 0; MORtmEntity *entity = [MORtmEntity new]; entity.type = MOPKStatus; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmEntity *)prepareRtmAboutKickSomeOneWith:(NSString *)userId AndRoomId:(NSString *)roomId{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.userId = userId; jsonEntity.roomId = roomId; MORtmEntity *entity = [MORtmEntity new]; entity.type = MORtmKick; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmEntity *)prepareRtmAboutSilenceSomeOneWith:(NSString *)userId AndRoomId:(NSString *)roomId And:(BOOL)isSilence{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.userId = userId; jsonEntity.roomId = roomId; jsonEntity.silence = isSilence; MORtmEntity *entity = [MORtmEntity new]; entity.type = MORtmChatSilence; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } /// 准备一条管理员信息 /// - Parameters: /// - userId: 用户ID /// - roomId: 房间ID + (MORtmEntity *)prepareRtmAboutManageSomeOneWith:(NSString *)userId AndRoomId:(NSString *)roomId And:(BOOL)isManager{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.userId = userId; jsonEntity.roomId = roomId; jsonEntity.manager = isManager; MORtmEntity *entity = [MORtmEntity new]; entity.type = MORtmChatManage; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } /// 准备一条提示信息 /// - Parameters: /// - roomId: 房间ID /// - type: // 1: 关注 2: PK 3:禁言 /// - status: // 1: 关注 (1关注 0取关) 2: PK(0:失败 1: 胜利 2: 自己投降3:对方投降) 3:(0解除禁言 1禁言) /// - content: //提示内容, 有些类型需要 (非必传) + (MORtmEntity *)prePareRtmAboutRoomTipWithRoomId:(NSString *)roomId AndType:(NSInteger)type AndStatus:(NSInteger)status AndTipContent:(NSString *)content AndUserName:(NSString *)userName{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.roomId = roomId ? roomId : @""; jsonEntity.type = type ? type : 0; jsonEntity.status = status ? status : 0; jsonEntity.tipContent = content ? content : @""; jsonEntity.userName = userName ? userName : @""; MORtmEntity *entity = [MORtmEntity new]; entity.type = MORtmRoomTip; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; //PK 兼容安卓 if(userName.length == 0){ jsonEntity.userName = entity.user.username; } return entity; } // 准备一条 房间挂起的Rtm + (MORtmEntity *)prePareRtmAboutRoomTipWithRoomId:(NSString *)roomId AndType:(NSInteger)type AndStatus:(NSInteger)status AndTipContent:(NSString *)content AndUserName:(NSString *)userName AndSuspend:(double)suspend{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.roomId = roomId ? roomId : @""; jsonEntity.type = type ? type : 0; jsonEntity.status = status ? status : 0; jsonEntity.tipContent = content ? content : @""; jsonEntity.userName = userName ? userName : @""; jsonEntity.suspendExpire = suspend; MORtmEntity *entity = [MORtmEntity new]; entity.type = MORtmRoomTip; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmEntity *)prePareRtmAboutLikeComboWithRoomId:(NSString *)roomId AndType:(NSInteger)type AndLikeNum:(NSInteger)likeNum{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.roomId = roomId ? roomId : @""; jsonEntity.type = type ? type : 0; jsonEntity.likeCombo = likeNum ? likeNum : 0; MORtmEntity *entity = [MORtmEntity new]; entity.type = MOLikeComboTip; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmEntity *)prePareRtmAboutWishListWithRoomId:(NSString *)roomId AndWishList:(NSArray *)wishList{ NSMutableArray *needWishArr = [NSMutableArray array]; for (MOWishStatusList *object in wishList) { MORtmWishList *tipObject = [[MORtmWishList alloc] init]; tipObject.giftCode = object.giftCode; tipObject.complete = (NSInteger)object.complete; tipObject.num = (NSInteger)object.num; tipObject.done = object.done; [needWishArr addObject:tipObject]; } MORtmEntity *entity = [MORtmEntity new]; entity.type = MOWishListTip; entity.data = needWishArr; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } /// 准备一条语言翻译的Rtm /// - Parameters: /// - roomId: 房间ID /// - wishList: 接口数组 + (MORtmEntity *)prePareRtmAboutTranslateArrWithRoomId:(NSString *)roomId AndTranslateArr:(NSArray *)translateArr{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.translateArr = translateArr; MORtmEntity *entity = [MORtmEntity new]; entity.type = MORoomVoiceTranslate; entity.data = jsonEntity; entity.roomId = roomId ? roomId : @""; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (MORtmEntity *)prepareRtmAboutGetRedTipWithSendUserName:(NSString *)sendUserName RedId:(NSString *)redEId{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.redSendName = sendUserName; jsonEntity.redEId = redEId; MORtmEntity *entity = [MORtmEntity new]; entity.type = SystemTipGetRed; entity.data = jsonEntity; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } /// 准备一条房间转换Rtm + (MORtmEntity *)prepareRtmAboutChangeRoomTypeWithRoomId:(NSString *)roomId AndType:(NSInteger)type AndPlanConvertTime:(double)planConvertTime AndDiamond:(double)diamond{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.type = type; jsonEntity.roomId = roomId ? roomId : @""; jsonEntity.planConvertTime = planConvertTime; jsonEntity.diamond = diamond; MORtmEntity *entity = [MORtmEntity new]; entity.type = MOChangeRoomType; entity.data = jsonEntity; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; return entity; } + (NSString *)insertString:(NSString *)insertText intoString:(NSString *)original { if (original.length == 0) return insertText; NSRange atRange = [original rangeOfString:@"@"]; NSMutableString *result = [NSMutableString stringWithString:original]; if (atRange.location != NSNotFound) {// @ 存在,插入到它后面 [result insertString:insertText atIndex:(atRange.location + 1)]; } else {// @ 不存在,插入到开头 [result insertString:[NSString stringWithFormat:@"@%@", insertText] atIndex:0]; } return [result copy]; } /// 打招呼需求本地构造一条被房主艾特的消息 + (MORtmEntity *)prepareLocalChatMessage:(MOUserBase *)userModel content:(NSString *)content { MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; NSString *contentResult = [self insertString:GetNickName intoString:content]; jsonEntity.content = contentResult; jsonEntity.danmu = NO; jsonEntity.atList = GetUserId; jsonEntity.atNameList = GetNickName; MORtmEntity *entity = [MORtmEntity new]; entity.data = jsonEntity; MORtmUser *userInfo = [MORtmEntity createSender:userModel]; entity.user = userInfo; entity.type = MORtmChat; return entity; } /// 准备一条通用提示消息RoomTipTwo + (MORtmEntity *)prepareRoomTipTwoMessage:(NSInteger)type AndUserName:(NSString *)userName AndRoomId:(NSString *)roomId AndTipNormalNum:(NSInteger)tipNormalNum{ MORtmJosnEntity *jsonEntity = [MORtmJosnEntity new]; jsonEntity.type = type; jsonEntity.userName = userName ? userName : @""; jsonEntity.roomId = roomId ? roomId : @""; jsonEntity.tipNormalNum = tipNormalNum ? tipNormalNum : 0; MORtmEntity *entity = [MORtmEntity new]; entity.data = jsonEntity; MORtmUser *userInfo = [MORtmEntity prepareBaseUser]; entity.user = userInfo; entity.type = MORoomTipTwo; return entity; } /// 自己构造发送人的信息 + (MORtmUser *)createSender:(MOUserBase *)userModel { MORtmUser *userInfo = [MORtmUser new]; userInfo.userId = userModel.userProfile.id; userInfo.username = userModel.userProfile.nickname; userInfo.avatar = userModel.userProfile.avatar; userInfo.agoraId = userModel.userProfile.agoraId; userInfo.bubble = userModel.userProfile.adornment.bubbleCode; userInfo.headress = @"";//使用了新字段headRes userInfo.level = userModel.level; userInfo.rides = 0; //vip MORtmVipBean *vipInfo = [MORtmVipBean new]; vipInfo.type = userModel.vipType; userInfo.vip = vipInfo; //粉丝团 MORtmFanBean *fanInfo = [MORtmFanBean new]; MOUserAnchorClub *fanClubData = userModel.userAnchorClub; if(fanClubData.id.length > 0){ fanInfo.level = fanClubData.level; fanInfo.name = fanClubData.nameplate; userInfo.fans = fanInfo; } //勋章Code数组 NSArray *medalArr = [userModel.userProfile.medalList valueForKey:@"code"]; if(medalArr.count > 0){ userInfo.medalCodeList = medalArr; } //MORtmHeaddress 头像对象 MORtmHeaddress *headdress = [MORtmHeaddress new]; headdress.type = userModel.userProfile.adornment.headgearType; headdress.res = userModel.userProfile.adornment.headgearRes; userInfo.headressObject = headdress; return userInfo; } #pragma mark - ChangeObject + (MOUserProfile *)toCreateUserProfileWith:(MORtmUser *)user{ MOUserProfile *result = [[MOUserProfile alloc] init]; if(user){ result.id = user.id; if(result.id.length == 0){ result.id = user.userId; } result.nickname = user.nickname; if(result.nickname.length == 0){ result.nickname = user.username; } result.agoraId = user.agoraId; result.avatar = user.avatar; MOAdornment *adorment = [[MOAdornment alloc] init]; adorment.enterBar = user.rides; adorment.headgearType = user.headdress.type; adorment.headgearRes = user.headdress.res; result.adornment = adorment; MOHeaddress *headdress = [[MOHeaddress alloc] init]; headdress.headgearType = user.headdress.type; headdress.headgearRes = user.headdress.res; result.headdress = headdress; result.vipType = user.vip.type; MODressing *dressing = [MORtmEntity toCreateUserProfileDressingWith:user]; result.dressing = dressing; } return result; } + (MODressing *)toCreateUserProfileDressingWith:(MORtmUser *)user{ MODressing *dressing = [[MODressing alloc] init]; dressing.rewardBanner = user.dressing.rewardBanner; dressing.bubble = user.dressing.bubble; dressing.enterFloating = user.dressing.enterFloating; dressing.linkMicFrame = user.dressing.linkMicFrame; dressing.entryBar = user.dressing.entryBar; dressing.cardFrame = user.dressing.cardFrame; dressing.liveBarrage = user.dressing.liveBarrage; return dressing; } + (MOLinkMic *)toCreateLinkMicObjectWith:(MORTMLinkMic *)inObject{ MOLinkMic *result = [[MOLinkMic alloc] init]; result.profile = [MORtmEntity toCreateUserProfileWith:inObject.user]; result.lock = inObject.lock; result.video1 = inObject.video1; result.video2 = inObject.video2; result.audio1 = inObject.audio1; result.audio2 = inObject.audio2; result.admin = inObject.admin; result.goldenBean = inObject.goldenBean; NSDictionary *dressing = [inObject.user.dressing modelToJSONObject]; result.dressing = [MODressing modelWithJSON:dressing]; return result; } + (MOLinkMic *)toCreateLinkMicObjectWithEntity:(MORtmEntity *)entity{ MORtmJosnEntity *jsonEntity = (MORtmJosnEntity *)entity.data; MOUserProfile *userProfile = [MOUserProfile new]; userProfile.id = jsonEntity.userId; userProfile.avatar = jsonEntity.avatar; userProfile.agoraId = jsonEntity.agoraId; userProfile.nickname = jsonEntity.userName; MOLinkMic *linkMic = [MOLinkMic new]; linkMic.video = (jsonEntity.type == 1) ? YES : NO; linkMic.profile = userProfile; linkMic.video1 = jsonEntity.video1; linkMic.video2 = jsonEntity.video2; linkMic.audio1 = jsonEntity.audio1; linkMic.audio2 = jsonEntity.audio2; linkMic.admin = jsonEntity.admin; return linkMic; } @end