|
@@ -32,6 +32,7 @@
|
|
|
#import "KSChatLiveMessage.h"
|
|
|
|
|
|
#import "LiveSeatActionView.h"
|
|
|
+
|
|
|
typedef NS_ENUM(NSInteger, LIVEPAGE) {
|
|
|
LIVEPAGE_PREVIEW,
|
|
|
LIVEPAGE_LIVE,
|
|
@@ -59,14 +60,14 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
|
|
|
|
|
|
#pragma mark ------- 直播房间信息
|
|
|
/*!
|
|
|
- 身份状态 主讲人/观众
|
|
|
+ 身份状态 老师/观众
|
|
|
*/
|
|
|
@property (nonatomic, assign) RCRTCLiveRoleType liveRoleType;
|
|
|
-/// 主讲人id
|
|
|
+/// 老师id
|
|
|
@property (nonatomic, strong) NSString *createrId;
|
|
|
-/// 主讲人名称
|
|
|
+/// 老师名称
|
|
|
@property (nonatomic, strong) NSString *createrName;
|
|
|
-/// 主讲人头像
|
|
|
+/// 老师头像
|
|
|
@property (nonatomic, strong) NSString *createrAvatal;
|
|
|
|
|
|
// 是否禁止连麦
|
|
@@ -88,7 +89,7 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
|
|
|
|
|
|
@property (nonatomic, assign) BOOL isImConnected;
|
|
|
|
|
|
-@property (nonatomic, assign) BOOL hasSendWelcomeMessage;
|
|
|
+@property (nonatomic, assign) BOOL hasJoinRoomSuccess;
|
|
|
|
|
|
@property (nonatomic, strong) KSLiveStreamVideo *localVideo;
|
|
|
|
|
@@ -260,7 +261,7 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
|
|
|
break;
|
|
|
case PREVIEWLIVEACTION_SWITCH: // 切换
|
|
|
{
|
|
|
- [[RCRTCEngine sharedInstance].defaultVideoStream switchCamera];
|
|
|
+ [self switchCamera];
|
|
|
}
|
|
|
break;
|
|
|
case PREVIEWLIVEACTION_BEAUTY: // 美颜
|
|
@@ -600,15 +601,8 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
|
|
|
[[RCIMClient sharedRCIMClient] joinChatRoom:self.roomId messageCount:-1 success:^{
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
[self addConstMessage];
|
|
|
+ self.hasJoinRoomSuccess = YES;
|
|
|
});
|
|
|
- KSLiveChatroomWelcome *joinChatroomMessage = [[KSLiveChatroomWelcome alloc] init];
|
|
|
- [joinChatroomMessage setMsgId:[RCIM sharedRCIM].currentUserInfo.userId];
|
|
|
- MJWeakSelf;
|
|
|
- [self sendMessage:joinChatroomMessage displayMessage:NO callback:^(BOOL success) {
|
|
|
- weakSelf.hasSendWelcomeMessage = YES;
|
|
|
- }];
|
|
|
- // 加入成功发送消息
|
|
|
-
|
|
|
} error:^(RCErrorCode status) {
|
|
|
if (status == RC_CHATROOM_NOT_EXIST || status == KICKED_FROM_CHATROOM || status == RC_PARAMETER_INVALID_CHATROOM) {
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -636,7 +630,7 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
|
|
|
|
|
|
dispatch_main_async_safe(^{
|
|
|
// IM 连接成功回调
|
|
|
- if (self.hasSendWelcomeMessage) { // 如果已经发送了进入消息
|
|
|
+ if (self.hasJoinRoomSuccess) { // 如果已经发送了进入消息
|
|
|
// 查询是否直播间开启
|
|
|
[KSNetworkingManager speakerCheckRoomInfoRequest:KS_GET roomUid:self.roomId success:^(NSDictionary * _Nonnull dic) {
|
|
|
if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
@@ -644,7 +638,7 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
|
|
|
MJWeakSelf;
|
|
|
[self notiferJoinSuccessToServiceCallback:^{
|
|
|
[weakSelf MBPShow:@"IM连接成功"];
|
|
|
- [weakSelf sendWelcomeMessage];
|
|
|
+ [weakSelf joinChatRoomAndLiveRoom];
|
|
|
}];
|
|
|
}
|
|
|
else {
|
|
@@ -661,19 +655,27 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-- (void)sendWelcomeMessage {
|
|
|
- MJWeakSelf;
|
|
|
+- (void)joinChatRoomAndLiveRoom {
|
|
|
+
|
|
|
[[RCIMClient sharedRCIMClient] joinExistChatRoom:self.roomId messageCount:-1 success:^{
|
|
|
- KSLiveChatroomWelcome *joinChatroomMessage = [[KSLiveChatroomWelcome alloc] init];
|
|
|
- [joinChatroomMessage setMsgId:[RCIM sharedRCIM].currentUserInfo.userId];
|
|
|
- [self sendMessage:joinChatroomMessage displayMessage:NO callback:^(BOOL success) {
|
|
|
- [weakSelf joinRTCRoom];
|
|
|
+ MJWeakSelf;
|
|
|
+ [self leaveRTCRoomCallback:^(BOOL success) {
|
|
|
+ dispatch_main_async_safe(^{
|
|
|
+ [weakSelf joinRTCRoom];
|
|
|
+ });
|
|
|
}];
|
|
|
+
|
|
|
} error:^(RCErrorCode status) {
|
|
|
NSLog(@"error code %zd" ,status);
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+- (void)leaveRTCRoomCallback:(void(^)(BOOL success))callback {
|
|
|
+ [[RCRTCEngine sharedInstance] leaveRoom:^(BOOL isSuccess, RCRTCCode code) {
|
|
|
+ callback(isSuccess);
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
- (void)joinRTCRoom {
|
|
|
[self setRoleType];
|
|
|
}
|
|
@@ -703,8 +705,8 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
|
|
|
}
|
|
|
|
|
|
- (void)connectionService {
|
|
|
- [self setRoleType];
|
|
|
[self joinChatRoom];
|
|
|
+ [self setRoleType];
|
|
|
}
|
|
|
|
|
|
- (void)countLikeMessageCount {
|
|
@@ -773,8 +775,6 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
|
|
|
for (LiveSeatMember *member in seatApplyArray) {
|
|
|
if ([member.userId isEqualToString:userId]) {
|
|
|
containUser = YES;
|
|
|
-// NSLog(@"---- continue --");
|
|
|
-// continue;
|
|
|
}
|
|
|
}
|
|
|
if (containUser == NO) {
|
|
@@ -1001,7 +1001,6 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
|
|
|
if (code == RCRTCCodeSignalServerNotConnect || code == RCRTCCodeParameterError || code == RCRTCCodeNotInRTCRoom || code == RCRTCCodeRTCTokenIsNull || code == RCRTCCodeHttpTimeoutError || code == RCRTCCodeHttpError || code == RCRTCCodeVoIPNotAvailable) {
|
|
|
NSLog(@"%@",[NSString stringWithFormat:@"加入失败 code %ld",code]);
|
|
|
[strongSelf MBPShow:@"加入直播间失败"];
|
|
|
- // [strongSelf.navigationController dismissViewControllerAnimated:YES completion:nil];
|
|
|
}
|
|
|
else {
|
|
|
[strongSelf notiferJoinSuccessToServiceCallback:^{
|
|
@@ -1055,10 +1054,6 @@ typedef NS_ENUM(NSInteger, LIVEPAGE) {
|
|
|
if (code == RCRTCCodeSuccess) {
|
|
|
weakSelf.needPublishStream = NO;
|
|
|
[weakSelf renderSeatView];
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- [weakSelf MBPShow:@"视频流发布失败"];
|
|
|
}
|
|
|
}];
|
|
|
}
|