个播随机PK匹配计时、取消匹配逻辑

This commit is contained in:
chenguilong
2022-11-23 19:52:03 +08:00
committed by fengshuo
parent ce74d273b2
commit f8a5546b33
15 changed files with 297 additions and 18 deletions

View File

@@ -91,6 +91,7 @@
#import "XPAnchorPkPanelView.h"
#import "XPWebViewController.h"
#import "XPRoomPKProgressView.h"
#import "XPAnchorPKMatchView.h"
@interface XPRoomFunctionContainerView ()<XPAcrpssRoomPKPanelViewDelegate, XPRoomLittleGameListViewDelegate, XPAnchorPkPanelViewDelegate, XPRoomBackMusicPlayerViewDelegate, XPRoomNewUserGreetViewDelegate, XPWishGiftViewControllerDelegate>
///host
@@ -115,6 +116,8 @@
@property (nonatomic,strong) XPAcrpssRoomPKPanelView *acrossPKPanelView;
///PK
@property (nonatomic, strong) XPAcrossRoomPKCountDownView *acrossPKCountView;
///PK
@property (nonatomic, strong) XPAnchorPKMatchView *anchorPKMatchView;
///
@property (nonatomic,strong) XPLittleGameMiniStageView *littleGameMiniView;
///
@@ -169,7 +172,7 @@
self.delegate = delegate;
[self initSubViews];
[self initSubViewConstraints];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(beginMatchAnchorPK) name:@"anchorPKMatchBegin" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(beginMatchAnchorPK:) name:@"anchorPKMatchBegin" object:nil];
}
return self;
}
@@ -455,8 +458,23 @@
}
#pragma mark - PK
- (void)beginMatchAnchorPK {
- (void)beginMatchAnchorPK:(NSNotification *)noti {
if (!self.anchorPKMatchView.superview) {
[self addSubview:self.anchorPKMatchView];
self.anchorPKMatchView.roomUid = [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].uid];
[self.anchorPKMatchView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.contributeEnterView.mas_bottom).mas_offset(5+37+5);
make.left.mas_equalTo(0);
make.width.height.mas_equalTo(52);
}];
NSDictionary *dict = noti.object;
NSNumber *startTime = dict[@"matchPkStartTime"];
self.delegate.getRoomInfo.pkMatchStartTime = [startTime longLongValue];
NSDate *datenow = [NSDate date];
long time2 = (long)([datenow timeIntervalSince1970]*1000);
long aTime = (time2 - self.delegate.getRoomInfo.pkMatchStartTime) / 1000;
[self.anchorPKMatchView openCountdownWithTime:aTime];
}
}
#pragma mark - RoomGuestDelegate
@@ -604,6 +622,8 @@
[self handleNewUserRoomGift];
///
[self configWishGiftEnter];
///PK
[self handleMatchAnchorPK];
}
- (void)onRoomMiniEntered {
@@ -776,6 +796,7 @@
break;
case Custom_Message_Sub_AnchorPK_Accept://PK
{
[self.anchorPKMatchView removeFromSuperview];
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.roomId];
request.userIds = @[[AccountInfoStorage instance].getUid];
@@ -829,6 +850,7 @@
break;
case Custom_Message_Sub_AnchorPK_Panel://PK
{
[self.anchorPKMatchView removeFromSuperview];
if (!self.anchorPKPanelView.superview) {
[self addSubview:self.anchorPKPanelView];
[self.anchorPKPanelView mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -876,6 +898,18 @@
case Custom_Message_Sub_PK_BeginTime:{
long long time = [attachment.data[@"beginTime"] longLongValue];
[self showAcrossPkCountDownViewWithTime:time];
}
break;
case Custom_Message_Sub_AnchorPK_Match_TimeOut:
{///PK
self.delegate.getRoomInfo.pkMatchStartTime = nil;
self.anchorPKMatchView.roomUid = [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].uid];
[self.anchorPKMatchView handleMatchTimeOutMessage];
}
break;
case Custom_Message_Sub_AnchorPK_MuteOtherMic:///PK
{
}
break;
default:
@@ -1771,6 +1805,23 @@
}
}
#pragma mark - PK
- (void)handleMatchAnchorPK {
if (self.delegate.getRoomInfo.pkMatchStartTime) {
[self addSubview:self.anchorPKMatchView];
self.anchorPKMatchView.roomUid = [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].uid];
[self.anchorPKMatchView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.contributeEnterView.mas_bottom).mas_offset(5+37+5);
make.left.mas_equalTo(0);
make.width.height.mas_equalTo(52);
}];
NSDate *datenow = [NSDate date];
long time2 = (long)([datenow timeIntervalSince1970]*1000);
long aTime = (time2 - self.delegate.getRoomInfo.pkMatchStartTime) / 1000;
[self.anchorPKMatchView openCountdownWithTime:aTime];
}
}
#pragma mark - Getters And Setters
- (XPRoomRankEntranceView *)contributeEnterView {
if (!_contributeEnterView) {
@@ -1933,6 +1984,13 @@
return _acrossPKCountView;
}
- (XPAnchorPKMatchView *)anchorPKMatchView {
if (!_anchorPKMatchView) {
_anchorPKMatchView = [[XPAnchorPKMatchView alloc] initWithDelegate:self.delegate];
}
return _anchorPKMatchView;
}
- (XPWishGiftEnterView *)wishGiftView {
if (!_wishGiftView) {
_wishGiftView = [[XPWishGiftEnterView alloc] init];