个播房请求上麦,弹出关注主播窗口

This commit is contained in:
chenguilong
2022-02-15 17:23:18 +08:00
parent 0ce0b911ad
commit 8d9ece2829
12 changed files with 673 additions and 25 deletions

View File

@@ -8,6 +8,8 @@
#import "XPRoomFunctionContainerView.h"
///Third
#import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h>
#import <NIMSDK/NIMSDK.h>
///Tool
#import "XPMacro.h"
#import "AccountInfoStorage.h"
@@ -17,12 +19,16 @@
#import "Api+Room.h"
#import "XCHudTool.h"
#import "XPHtmlUrl.h"
#import "Api+Mine.h"
///Model
#import "RoomInfoModel.h"
#import "MicroQueueModel.h"
#import "UserInfoModel.h"
#import "AttachmentModel.h"
///View
#import "XPRoomHalfWebView.h"
#import "XPAnchorAudienceUpMicView.h"
#import "XPRoomAnchorInfoCardView.h"
@interface XPRoomFunctionContainerView ()
///host
@property (nonatomic,weak) id<RoomHostDelegate>delegate;
@@ -30,6 +36,8 @@
@property (nonatomic,strong) UIButton *contributionButton;
///
@property (nonatomic,strong) UIButton *datingProgresButton;
///
@property (nonatomic, strong) dispatch_source_t followAnchorTimer;
@end
@implementation XPRoomFunctionContainerView
@@ -94,6 +102,39 @@
}
}
- (void)onRoomEntered {
RoomInfoModel * roomInfo = self.delegate.getRoomInfo;
NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
if (roomInfo.type == RoomType_Anchor && ![[AccountInfoStorage instance].getUid isEqualToString:roomUid]) {//
NSString * uid = [[AccountInfoStorage instance] getUid];
[Api attentionStatusCompletion:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {//
BOOL isLike = ((NSNumber *)data.data).boolValue;
if (!isLike) {
[self setFollowAnchorTimer];
}
} uid:uid isLikeUid:roomUid];
}
}
- (void)handleNIMCustomMessage:(NIMMessage *)message {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_AnchorRoom_AudienceUpMic) {
UserInfoModel *model = [UserInfoModel modelWithJSON:attachment.data];
XPAnchorAudienceUpMicView *upMicView = [[XPAnchorAudienceUpMicView alloc] initWithFrame:CGRectMake(0, 0, 300, 226) delegate:self.delegate];
upMicView.info = model;
TTPopupConfig *config = [[TTPopupConfig alloc] init];
config.filterIdentifier = @"audienceRequestUpMic";
config.shouldFilterPopup = YES;
config.contentView = upMicView;
config.style = TTPopupStyleAlert;
[TTPopup popupWithConfig:config];
}
}
}
#pragma mark - Event Response
- (void)contributionButtonAction:(UIButton *)sender {
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid];
@@ -131,6 +172,54 @@
}];}
#pragma mark -
- (void)setFollowAnchorTimer {
if (self.followAnchorTimer != nil) {
dispatch_source_cancel(self.followAnchorTimer);
}
#ifdef DEBUG
NSInteger totalTime = 5;
#else
NSInteger totalTime = 420;
#endif
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
self.followAnchorTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(self.followAnchorTimer,dispatch_walltime(NULL, totalTime*NSEC_PER_SEC), totalTime*NSEC_PER_SEC, 0); //
@weakify(self);
dispatch_source_set_event_handler(self.followAnchorTimer, ^{
dispatch_async(dispatch_get_main_queue(), ^{
@strongify(self);
dispatch_source_cancel(self.followAnchorTimer);
RoomInfoModel* roomInfo = self.delegate.getRoomInfo;
NSString *roomUid = [NSString stringWithFormat:@"%zd", roomInfo.uid];
NSString * uid = [[AccountInfoStorage instance] getUid];
[Api attentionStatusCompletion:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
BOOL isLike = ((NSNumber *)data.data).boolValue;
if (!isLike) { //
if (self.window) {
[self showFollowAnchorView];
}
}
} uid:uid isLikeUid:roomUid];
});
});
dispatch_resume(self.followAnchorTimer);
}
//
- (void)showFollowAnchorView {
RoomInfoModel* roomInfo = self.delegate.getRoomInfo;
NSString *roomUid = [NSString stringWithFormat:@"%zd", roomInfo.uid];
[Api getUserInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
UserInfoModel *userInfo = [UserInfoModel modelWithDictionary:data.data];
XPRoomAnchorInfoCardView *view = [[XPRoomAnchorInfoCardView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 300)];
view.userInfo = self.delegate.getUserInfo;
view.targetUserInfo = userInfo;
view.roomId =roomInfo.roomId;
[TTPopup popupView:view style:TTPopupStyleActionSheet];
} uid:roomUid];
}
#pragma mark - Getters And Setters
- (UIButton *)contributionButton {
if (!_contributionButton) {