diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.m b/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.m index f15509bd..94a68cff 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/Presenter/MSRoomGamePresenter.m @@ -63,11 +63,20 @@ } ///开始匹配游戏 -(void)startMatchGameWithroomId:(NSString *)roomId mgId:(NSString *)mgId gameMode:(NSString *)gameMode{ + @kWeakify(self); [Api startMatchGame:[self createHttpCompletion:^(BaseModel * _Nonnull data) { + @kStrongify(self); [[self getView]startMatchGameSuccess]; } fail:^(NSInteger code, NSString * _Nullable msg) { - - } showLoading:YES errorToast:YES] roomId:roomId mgId:mgId gameMode:gameMode]; + if (code == 34792) { // 特殊操作,后续优化 + [TTPopup alertWithMessage:msg confirmHandler:^{ + @kStrongify(self); + [[self getView] forceExitRoom]; + } cancelHandler:^{}]; + } else { + [[self getView] showErrorToast:msg]; + } + } showLoading:YES errorToast:NO] roomId:roomId mgId:mgId gameMode:gameMode]; } ///得到房间详情 -(void)getRoomGameDetailWithRoomType:(NSString *)roomType{ diff --git a/YuMi/Modules/YMRoom/View/RoomGame/Protocol/MSRoomGameProtocol.h b/YuMi/Modules/YMRoom/View/RoomGame/Protocol/MSRoomGameProtocol.h index 41cb8c93..572b3324 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/Protocol/MSRoomGameProtocol.h +++ b/YuMi/Modules/YMRoom/View/RoomGame/Protocol/MSRoomGameProtocol.h @@ -18,6 +18,8 @@ NS_ASSUME_NONNULL_BEGIN -(void)getRoomGameConfigSuccessWithUser:(UserInfoModel *)user gameModel:(MSTabbarRoomGameModel *)gameModel; ///开始游戏 -(void)startMatchGameSuccess; +///用户选择退出房间并重新排位 +-(void)forceExitRoom; ///得到游戏详情 -(void)getRoomGameDetailsSuccessWithModel:(MSRoomGameModel *)model; ///得到金币数量 diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.h b/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.h index 7ec3973d..93106065 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.h +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.h @@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN @interface MSTabbarRoomGameVC : MvpViewController +@property (nonatomic, copy) void(^needForceExitRoom)(void); + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m b/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m index ec63889f..cc9203be 100644 --- a/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m +++ b/YuMi/Modules/YMRoom/View/RoomGame/View/MSTabbarRoomGameVC.m @@ -119,6 +119,17 @@ } +- (void)forceExitRoom { + if (_needForceExitRoom) { + _needForceExitRoom(); + @kWeakify(self); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + @kStrongify(self); + [self startMatchGameActionWithModel:self.chooseGameModel]; + }); + } +} + #pragma mark - MSRoomGameProtocol ///得到金币数量 diff --git a/YuMi/Modules/YMTabbar/View/TabbarViewController.m b/YuMi/Modules/YMTabbar/View/TabbarViewController.m index 1db5fcf9..44a20b8a 100644 --- a/YuMi/Modules/YMTabbar/View/TabbarViewController.m +++ b/YuMi/Modules/YMTabbar/View/TabbarViewController.m @@ -754,8 +754,20 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey; // viewController = [[XPNewHomeViewController alloc] init]; viewController = [[XPHomePagingViewController alloc] init]; break; - case 1: - viewController = [[MSTabbarRoomGameVC alloc] init]; + case 1: { + @kWeakify(self); + MSTabbarRoomGameVC *vc = [[MSTabbarRoomGameVC alloc] init]; + vc.needForceExitRoom = ^{ + @kStrongify(self); + if ([XPRoomMiniManager shareManager].getRoomInfo) { + [[RtcManager instance] exitRoom]; + [[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId] + completion:nil]; + [self.roomMineView hiddenRoomMiniView]; + } + }; + viewController = vc; + } break; case 2: viewController = [[XPMomentsViewController alloc] init];