105 lines
3.8 KiB
Mathematica
105 lines
3.8 KiB
Mathematica
|
|
//
|
|||
|
|
// BJRoomManager.m
|
|||
|
|
//
|
|||
|
|
//
|
|||
|
|
// Created by ybb on 2021/5/18.
|
|||
|
|
// Copyright © 2021 . All rights reserved.
|
|||
|
|
//
|
|||
|
|
|
|||
|
|
#import "BJRoomManager.h"
|
|||
|
|
#import "BJFloatRoomManager.h"
|
|||
|
|
#import "SARoomPswAlert.h"
|
|||
|
|
#import "RCMicRoomViewController.h"
|
|||
|
|
|
|||
|
|
@interface BJRoomManager ()
|
|||
|
|
|
|||
|
|
@property (nonatomic, copy) NSString *nowRid, *nowPwd;
|
|||
|
|
|
|||
|
|
@end
|
|||
|
|
|
|||
|
|
@implementation BJRoomManager
|
|||
|
|
|
|||
|
|
singleton_implementation(BJRoomManager)
|
|||
|
|
|
|||
|
|
|
|||
|
|
+ (void)goMicRoomWithRid:(NSString *)rId withPwd:(nullable NSString *)pwd {
|
|||
|
|
//有浮标
|
|||
|
|
if (BJFloatRoomManager.sharedBJFloatRoomManager.viewModel) {
|
|||
|
|
if ([BJFloatRoomManager.sharedBJFloatRoomManager.viewModel.roomInfo.roomId isEqualToString:rId]) {
|
|||
|
|
[BJFloatRoomManager.sharedBJFloatRoomManager reEnterSameRoom];
|
|||
|
|
return;
|
|||
|
|
}else {
|
|||
|
|
[BJFloatRoomManager.sharedBJFloatRoomManager closeFloatWindow];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//没有浮标但在堆栈nav
|
|||
|
|
RCMicRoomViewController *curRoom;
|
|||
|
|
for (UIViewController *each in UIViewController.currentViewController.navigationController.viewControllers) {
|
|||
|
|
if ([each isKindOfClass:RCMicRoomViewController.class]) {
|
|||
|
|
curRoom = (RCMicRoomViewController *)each;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (curRoom) {
|
|||
|
|
if ([curRoom.yb_rid isEqualToString:rId]) {
|
|||
|
|
[UIViewController.currentViewController.navigationController popToViewController:curRoom animated:YES];
|
|||
|
|
return;
|
|||
|
|
}else {
|
|||
|
|
[curRoom doThingsBeforeQuitRoom];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//进入新的房间
|
|||
|
|
BJRoomManager.sharedBJRoomManager.nowRid = rId;
|
|||
|
|
BJRoomManager.sharedBJRoomManager.nowPwd = pwd;
|
|||
|
|
|
|||
|
|
NSDictionary *dict = @{@"rid":C_string(rId)};
|
|||
|
|
NSMutableDictionary *paras = [NSMutableDictionary dictionary];
|
|||
|
|
[paras addEntriesFromDictionary:dict];
|
|||
|
|
if (pwd.length > 0) {
|
|||
|
|
[paras setObject:C_string(pwd) forKey:@"password"];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
[SVProgressHUD showWithStatus:nil];
|
|||
|
|
[RCMicHTTP postWithURLString:@"/api/room/enter_room_info" parameters:paras response:^(RCMicHTTPResult *result) {
|
|||
|
|
[SVProgressHUD dismiss];
|
|||
|
|
if (result.success) {
|
|||
|
|
if (result.errorCode == 200 && [result.content isKindOfClass:NSDictionary.class]) {
|
|||
|
|
[result.content safeStringForKey:@""];
|
|||
|
|
RCMicRoomInfo *model = [RCMicRoomInfo mj_objectWithKeyValues:result.content];
|
|||
|
|
if (model.room_status.integerValue == 1 || model.room_status.integerValue == 3) {
|
|||
|
|
GVUSER.publicType = @"0";// ??
|
|||
|
|
GVUSER.is_calculator = model.is_calculator;// ??
|
|||
|
|
GVUSER.is_open_blindXlh = model.open_blind_box_term;
|
|||
|
|
RCMicRoomViewController *next = [[RCMicRoomViewController alloc] initWithRoomInfo:model Role:RCMicRoleType_Audience]; //退出房间不保持,所以刚进来都是audience
|
|||
|
|
[next pushSelf];
|
|||
|
|
}else {
|
|||
|
|
//room_status 2是封禁
|
|||
|
|
[SVProgressHUD showInfoWithStatus:@"房间被封禁"];
|
|||
|
|
}
|
|||
|
|
}else if (result.errorCode == 202 && BJRoomManager.sharedBJRoomManager.nowPwd.length==0) {
|
|||
|
|
// show pwd input
|
|||
|
|
[BJRoomManager.sharedBJRoomManager showPwdView];
|
|||
|
|
}
|
|||
|
|
else {
|
|||
|
|
[SVProgressHUD showInfoWithStatus:result.message];
|
|||
|
|
}
|
|||
|
|
}else {
|
|||
|
|
[SVProgressHUD showInfoWithStatus:@"网络错误"];
|
|||
|
|
}
|
|||
|
|
}];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
- (void)showPwdView {
|
|||
|
|
SARoomPswAlert *view = [[NSBundle mainBundle] loadNibNamed:@"SARoomPswAlert" owner:self options:nil].firstObject;
|
|||
|
|
view.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight);
|
|||
|
|
[KEYWINDOW addSubview:view];
|
|||
|
|
|
|||
|
|
WEAK_SELF
|
|||
|
|
view.onConfirmBlock = ^(NSString * _Nonnull pwd) {
|
|||
|
|
[BJRoomManager goMicRoomWithRid:weakSelf.nowRid withPwd:pwd];
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@end
|