|
@@ -7,7 +7,6 @@
|
|
|
//
|
|
|
|
|
|
#import "ClassroomService.h"
|
|
|
-#import "HTTPUtility.h"
|
|
|
#import "MemberChangeMessage.h"
|
|
|
#import "WhiteboardMessage.h"
|
|
|
#import "DeviceMessage.h"
|
|
@@ -124,59 +123,54 @@
|
|
|
}
|
|
|
|
|
|
#pragma mark - HTTP
|
|
|
+
|
|
|
- (void)joinClassroom:(NSString *)roomId
|
|
|
- userName:(NSString *)userName
|
|
|
-isAudience:(BOOL)audience
|
|
|
- success:(void (^)(Classroom *classroom))successBlock
|
|
|
- error:(void (^)(ErrorCode errorCode, NSString *message))errorBlock {
|
|
|
+ userName:(NSString *)userName
|
|
|
+ isAudience:(BOOL)audience
|
|
|
+ success:(void (^)(Classroom * _Nonnull))successBlock
|
|
|
+ error:(void (^)(ErrorCode, NSString * _Nonnull))errorBlock {
|
|
|
if (roomId.length == 0 || userName.length == 0) {
|
|
|
[self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
return;
|
|
|
}
|
|
|
- [HTTPUtility setAuthHeader:[NSString stringWithFormat:@"%@ %@", UserDefault(Token_type), UserDefault(TokenKey)]];
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:roomId forKey:@"roomId"];
|
|
|
- [dic setObject:@(audience) forKey:@"audience"];
|
|
|
- [dic setObject:userName forKey:@"userName"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/join"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
- NSDictionary *resultDic = result.content[@"result"];
|
|
|
-
|
|
|
- Classroom *room = [Classroom classroomFromJson:resultDic];
|
|
|
- self.currentRoom = room;
|
|
|
- if (successBlock) {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- successBlock(room);
|
|
|
- })
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (errorBlock) {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- errorBlock(result.errorCode, result.message);
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }];
|
|
|
+ [KSNetworkingManager roomJoinRequest:KS_POST roomId:roomId success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ Classroom *room = [Classroom classroomFromJson:[dic dictionaryValueForKey:@"data"]];
|
|
|
+ self.currentRoom = room;
|
|
|
+ if (successBlock) {
|
|
|
+ dispatch_main_async_safe(^{
|
|
|
+ successBlock(room);
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ errorBlock([dic integerValueForKey:@"code"], MESSAGEKEY);
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ if (errorBlock) {
|
|
|
+ dispatch_main_async_safe(^{
|
|
|
+ errorBlock(error.code, @"加入房间失败");
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
-- (void)joinRoomStatusNotify:(BOOL)requestStatus {
|
|
|
+- (void)joinRoomFailerNotify {
|
|
|
if (![self checkWhetherInRoom]) {
|
|
|
if ([self.classroomDelegate respondsToSelector:@selector(roomDidLeave)]) {
|
|
|
[self.classroomDelegate roomDidLeave];
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:self.currentRoom.roomId, @"roomId", self.currentRoom.currentMemberId, @"userId", @(requestStatus),@"requestStatus",[KeyChainTools getUUID],@"deviceNum",nil];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost URLString:@"room/joinRoomStatusNotify" parameters:dic response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
+ [KSNetworkingManager joinRoomFailureRequest:KS_POST roomId:self.currentRoom.roomId success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
NSLog(@"------ 通知成功");
|
|
|
}
|
|
|
else {
|
|
|
NSLog(@"------ 通知失败");
|
|
|
}
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ NSLog(@"------ 通知失败");
|
|
|
}];
|
|
|
}
|
|
|
|
|
@@ -188,543 +182,146 @@ isAudience:(BOOL)audience
|
|
|
return;
|
|
|
}
|
|
|
NSLog(@"leave classroom start");
|
|
|
- NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:self.currentRoom.roomId, @"roomId", self.currentRoom.currentMemberId, @"userId",nil];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/leave"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- SealClassLog(@"离开 ClassRoomService code = %ld",(long)result.httpCode);
|
|
|
- if (result.success) {
|
|
|
-// self.currentRoom = nil;
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(roomDidLeave)]) {
|
|
|
- [self.classroomDelegate roomDidLeave];
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(roomDidLeave)]) {
|
|
|
- [self.classroomDelegate roomDidLeave];
|
|
|
- }
|
|
|
- });
|
|
|
- NSLog(@"退出失败:%@",result);
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)getWhiteboardList:(void (^)(NSArray<Whiteboard *> * _Nullable))completeBlock {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- if (completeBlock) {
|
|
|
- completeBlock(nil);
|
|
|
+
|
|
|
+ [KSNetworkingManager roomLeaveRequest:KS_POST roomId:self.currentRoom.roomId success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ dispatch_main_async_safe(^{
|
|
|
+ if ([self.classroomDelegate respondsToSelector:@selector(roomDidLeave)]) {
|
|
|
+ [self.classroomDelegate roomDidLeave];
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
- return;
|
|
|
- }
|
|
|
- NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:self.currentRoom.roomId, @"roomId", nil];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodGet
|
|
|
- URLString:@"/room/whiteboard/list"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
- NSMutableArray *boardList = [[NSMutableArray alloc] init];
|
|
|
- NSArray *arr = result.content[@"result"];
|
|
|
- for (NSDictionary *boardDic in arr) {
|
|
|
- Whiteboard *board = [Whiteboard whiteboardFromJson:boardDic];
|
|
|
- [boardList addObject:board];
|
|
|
- }
|
|
|
- if (completeBlock) {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- completeBlock(boardList);
|
|
|
- });
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (completeBlock) {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- completeBlock(nil);
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }];
|
|
|
+ else {
|
|
|
+ dispatch_main_async_safe(^{
|
|
|
+ if ([self.classroomDelegate respondsToSelector:@selector(roomDidLeave)]) {
|
|
|
+ [self.classroomDelegate roomDidLeave];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ NSLog(@"退出失败:%@",MESSAGEKEY);
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ dispatch_main_async_safe(^{
|
|
|
+ if ([self.classroomDelegate respondsToSelector:@selector(roomDidLeave)]) {
|
|
|
+ [self.classroomDelegate roomDidLeave];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ NSLog(@"退出失败");
|
|
|
+ }];
|
|
|
}
|
|
|
|
|
|
+
|
|
|
// 下载伴奏完成回调
|
|
|
- (void)adjustAccompanySongNotifer:(NSString *)songId status:(BOOL)status {
|
|
|
if (![self checkWhetherInRoom]) {
|
|
|
[self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
return;
|
|
|
}
|
|
|
- NSMutableDictionary *dic = [NSMutableDictionary dictionary];
|
|
|
- [dic setValue:@(status) forKey:@"status"];
|
|
|
- [dic setValue:songId forKey:@"musicScoreAccompanimentId"];
|
|
|
- [dic setValue:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost URLString:@"room/adjustMusicScore" parameters:dic response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
- } else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
+
|
|
|
+ NSString *statusString = status == YES ? @"1" : @"2";
|
|
|
+ [KSNetworkingManager musicSheetDownNotifyRequest:KS_POST roomId:self.currentRoom.roomId status:statusString accompanimentId:songId success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+
|
|
|
}
|
|
|
+ else {
|
|
|
+ [self callbackFailureDescription:ErrorCodeOther];
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ [self callbackFailureDescription:ErrorCodeOther];
|
|
|
}];
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-#pragma mark 角色权限相关,仅助教有权限
|
|
|
-- (void)downgradeMembers:(NSArray <NSString *> *)members {
|
|
|
+#pragma mark 操作当前用户设备状态,仅老师/学员有权限
|
|
|
+- (void)enableDevice:(BOOL)enable
|
|
|
+ withType:(DeviceType)type {
|
|
|
if (![self checkWhetherInRoom]) {
|
|
|
[self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
return;
|
|
|
}
|
|
|
- if (members.count < 1) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- NSMutableArray *users = [[NSMutableArray alloc] init];
|
|
|
- for (NSString *userId in members) {
|
|
|
- if (userId.length > 0) {
|
|
|
- [users addObject:@{@"userId":userId,@"role":@(RoleAudience)}];
|
|
|
+
|
|
|
+ NSString *deviceType = [self getDeviceTypeDesc:type];
|
|
|
+
|
|
|
+ [KSNetworkingManager roomDeviceSync:KS_POST deviceType:deviceType roomId:self.currentRoom.roomId enable:enable success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ if (type == DeviceTypeMicrophone) {
|
|
|
+ [self.currentRoom updateMember:self.currentRoom.currentMember.userId forMicrophone:enable];
|
|
|
+ } else if (type == DeviceTypeCamera) {
|
|
|
+ [self.currentRoom updateMember:self.currentRoom.currentMember.userId forCamera:enable];
|
|
|
+ }
|
|
|
+ else if (type == DeviceTypeMusicMode) {
|
|
|
+ [self.currentRoom updateMember:self.currentRoom.currentMember.userId forMusicMode:enable];
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- [dic setObject:users forKey:@"users"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost URLString:@"/room/downgrade" parameters:dic response:^(HTTPResult *result) {
|
|
|
- if(result.success) {
|
|
|
- }else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
+ else {
|
|
|
+ [self callbackFailureDescription:ErrorCodeOther];
|
|
|
}
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ [self callbackFailureDescription:ErrorCodeOther];
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
-- (void)inviteUpgrade:(NSString *)userId {
|
|
|
+- (void)approveEnableDevice:(DeviceType)type {
|
|
|
if (![self checkWhetherInRoom]) {
|
|
|
[self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
return;
|
|
|
}
|
|
|
- if (userId.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [dic setObject:userId forKey:@"userId"];
|
|
|
- [dic setObject:@(RoleStudent) forKey:@"role"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/upgrade/invite"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
- } else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)assignTeacher:(NSString *)userId {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (userId.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [dic setObject:userId forKey:@"userId"];
|
|
|
- [dic setObject:@(RoleTeacher) forKey:@"role"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost URLString:@"/room/change-role" parameters:dic response:^(HTTPResult *result) {
|
|
|
- if(result.success){
|
|
|
- }else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
+
|
|
|
+ NSString *deviceType = [self getDeviceTypeDesc:type];
|
|
|
+
|
|
|
+ [KSNetworkingManager deviceApprove:KS_POST deviceType:deviceType roomId:self.currentRoom.roomId success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+
|
|
|
}
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)transferAssistant:(NSString *)userId {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (userId.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [dic setObject:userId forKey:@"userId"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost URLString:@"/room/transfer" parameters:dic response:^(HTTPResult *result) {
|
|
|
- if(result.success){
|
|
|
- }else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
+ else {
|
|
|
+ [self callbackFailureDescription:ErrorCodeOther];
|
|
|
}
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ [self callbackFailureDescription:ErrorCodeOther];
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
-- (void)approveUpgrade:(NSString *)ticket{
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (ticket.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [dic setObject:ticket forKey:@"ticket"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost URLString:@"/room/speech/approve" parameters:dic response:^(HTTPResult *result) {
|
|
|
- if(result.success){
|
|
|
- }else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
|
|
|
-- (void)rejectUpgrade:(NSString *)ticket {
|
|
|
+- (void)rejectEnableDevice:(DeviceType)type {
|
|
|
if (![self checkWhetherInRoom]) {
|
|
|
[self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
return;
|
|
|
}
|
|
|
- if (ticket.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [dic setObject:ticket forKey:@"ticket"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost URLString:@"/room/speech/reject" parameters:dic response:^(HTTPResult *result) {
|
|
|
- if(result.success){
|
|
|
- }else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
+ NSString *deviceType = [self getDeviceTypeDesc:type];
|
|
|
+ [KSNetworkingManager deviceReject:KS_POST deviceType:deviceType roomId:self.currentRoom.roomId success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+
|
|
|
}
|
|
|
+ else {
|
|
|
+ [self callbackFailureDescription:ErrorCodeOther];
|
|
|
+ }
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ [self callbackFailureDescription:ErrorCodeOther];
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
-- (void)kickMember:(NSString *)userId {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (userId.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [dic setObject:userId forKey:@"userId"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/kick"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
- } else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)enableDevice:(BOOL)enable
|
|
|
- type:(DeviceType)type
|
|
|
- forUser:(NSString *)userId {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (userId.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- if(DeviceTypeCamera == type) {
|
|
|
- [dic setObject:@(enable) forKey:@"cameraOn"];
|
|
|
- }else if (DeviceTypeMicrophone == type) {
|
|
|
- [dic setObject:@(enable) forKey:@"microphoneOn"];
|
|
|
- }
|
|
|
- else if (DeviceTypeHandup == type) {
|
|
|
- [dic setObject:@(enable) forKey:@"handUpOn"];
|
|
|
- }
|
|
|
- else if (DeviceTypeMusicMode == type) {
|
|
|
- [dic setObject:@(enable) forKey:@"musicModeOn"];
|
|
|
- }
|
|
|
- else if (DeviceTypeExamSong == type) {
|
|
|
- [dic setObject:@(enable) forKey:@"examSongOn"];
|
|
|
- }
|
|
|
- [dic setObject:userId forKey:@"userId"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/device/control"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
-
|
|
|
- } else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark 教室显示相关,仅助教/老师有权限
|
|
|
-- (void)createWhiteboard {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:self.currentRoom.roomId, @"roomId", nil];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/whiteboard/create"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
- Whiteboard *board = [[Whiteboard alloc] init];
|
|
|
- board.boardId = result.content[@"result"];
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(whiteboardDidCreate:)]) {
|
|
|
- [self.classroomDelegate whiteboardDidCreate:board];
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)deleteWhiteboard:(NSString *)boardId {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (boardId.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [dic setObject:boardId forKey:@"whiteboardId"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/whiteboard/delete"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
-
|
|
|
- } else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)display:(DisplayType)type
|
|
|
- withInfo:(NSString *)info {
|
|
|
- SealClassLog(@"display:%ld,info:%@,currentRoom.roomId=%@",type,info,self.currentRoom.roomId);
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (info.length == 0 || self.currentRoom.roomId.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [dic setObject:@(type) forKey:@"type"];
|
|
|
- if (type == DisplayWhiteboard) {
|
|
|
- [dic setObject:info forKey:@"uri"];
|
|
|
- } else {
|
|
|
- [dic setObject:info forKey:@"userId"];
|
|
|
- }
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/display"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
- self.currentRoom.currentDisplayType = type;
|
|
|
- self.currentRoom.currentDisplayURI = info;
|
|
|
- } else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)displayWhiteboard:(NSString *)boardId {
|
|
|
- if (boardId.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- [self display:DisplayWhiteboard withInfo:boardId];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)displayTeacher {
|
|
|
- [self display:DisplayTeacher withInfo:self.currentRoom.teacher.userId];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)displayAssistant {
|
|
|
- [self display:DisplayAssistant withInfo:self.currentRoom.assistant.userId];
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark 操作当前用户设备状态,仅助教/老师/学员有权限
|
|
|
-- (void)enableDevice:(BOOL)enable
|
|
|
- withType:(DeviceType)type {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- if (type == DeviceTypeCamera) {
|
|
|
- [dic setObject:@(enable) forKey:@"cameraOn"];
|
|
|
- } else if (type == DeviceTypeMicrophone) {
|
|
|
- [dic setObject:@(enable) forKey:@"microphoneOn"];
|
|
|
- }
|
|
|
- else if (type == DeviceTypeMusicMode) {
|
|
|
- [dic setObject:@(enable) forKey:@"musicModeOn"];
|
|
|
- }
|
|
|
- else if (type == DeviceTypeHandup) {
|
|
|
- [dic setObject:@(enable) forKey:@"handUpOn"];
|
|
|
- }
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/device/sync"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
- if (type == DeviceTypeMicrophone) {
|
|
|
- [self.currentRoom updateMember:self.currentRoom.currentMember.userId forMicrophone:enable];
|
|
|
- } else if (type == DeviceTypeCamera) {
|
|
|
- [self.currentRoom updateMember:self.currentRoom.currentMember.userId forCamera:enable];
|
|
|
- }
|
|
|
- else if (type == DeviceTypeMusicMode) {
|
|
|
- [self.currentRoom updateMember:self.currentRoom.currentMember.userId forMusicMode:enable];
|
|
|
- }
|
|
|
- } else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)approveEnableDevice:(NSString *)ticket {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (ticket.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [dic setObject:ticket forKey:@"ticket"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/device/approve"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
-
|
|
|
- } else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)rejectEnableDevice:(NSString *)ticket {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (ticket.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [dic setObject:ticket forKey:@"ticket"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/device/reject"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
-
|
|
|
- } else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-#pragma mark 旁观者升级相关,仅旁观者有权限
|
|
|
-- (void)applyUpgrade {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/speech/apply"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
-
|
|
|
- } else {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(applyDidFailed:)]) {
|
|
|
- [self.classroomDelegate applyDidFailed:result.errorCode];
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)approveInvite:(NSString *)ticket {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (ticket.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [dic setObject:ticket forKey:@"ticket"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/upgrade/approve"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
-
|
|
|
- } else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
- }
|
|
|
- }];
|
|
|
-}
|
|
|
+#pragma mark - Util
|
|
|
|
|
|
-- (void)rejectInvite:(NSString *)ticket {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- [self callbackFailureDescription:ErrorCodeUserNotExistInRoom];
|
|
|
- return;
|
|
|
+- (NSString *)getDeviceTypeDesc:(DeviceType)type {
|
|
|
+ switch (type) {
|
|
|
+ case DeviceTypeCamera:
|
|
|
+ return @"CAMERA";
|
|
|
+ case DeviceTypeMicrophone:
|
|
|
+ return @"MICROPHONE";
|
|
|
+ case DeviceTypeMusicMode:
|
|
|
+ return @"MUSIC_MODE";
|
|
|
+ case DeviceTypeHandup:
|
|
|
+ return @"HAND_UP";
|
|
|
+ case DeviceTypeExamSong:
|
|
|
+ return @"EXAM_SONG";
|
|
|
+ case DeviceTypeMusicScore:
|
|
|
+ return @"MUSIC_SHEET";
|
|
|
+ case DeviceTypeAccompany:
|
|
|
+ return @"ACCOMPANIMENT";
|
|
|
+ default:
|
|
|
+ return @"";
|
|
|
}
|
|
|
- if (ticket.length == 0) {
|
|
|
- [self callbackFailureDescription:ErrorCodeParameterError];
|
|
|
- return;
|
|
|
- }
|
|
|
- NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
|
|
|
- [dic setObject:self.currentRoom.roomId forKey:@"roomId"];
|
|
|
- [dic setObject:ticket forKey:@"ticket"];
|
|
|
- [HTTPUtility requestWithHTTPMethod:HTTPMethodPost
|
|
|
- URLString:@"/room/upgrade/reject"
|
|
|
- parameters:dic
|
|
|
- response:^(HTTPResult *result) {
|
|
|
- if (result.success) {
|
|
|
-
|
|
|
- } else {
|
|
|
- [self callbackFailureDescription:result.errorCode];
|
|
|
- }
|
|
|
- }];
|
|
|
}
|
|
|
|
|
|
-#pragma mark - Util
|
|
|
-- (NSString *)generateWhiteboardURL:(NSString *)boardId {
|
|
|
- if (![self checkWhetherInRoom]) {
|
|
|
- return nil;
|
|
|
- }
|
|
|
- Role role = self.currentRoom.currentMember.role;
|
|
|
- NSString *roomId = self.currentRoom.roomId;
|
|
|
- return [NSString stringWithFormat:@"%@&role=%@&roomId=%@&authorization=%@", boardId, @(role), roomId, self.auth];
|
|
|
-}
|
|
|
|
|
|
#pragma mark - Helper
|
|
|
- (BOOL)checkWhetherInRoom {
|
|
@@ -857,11 +454,7 @@ isAudience:(BOOL)audience
|
|
|
dispatch_main_async_safe(^{
|
|
|
[self.currentRoom updateDisplayUri:msg.display];
|
|
|
DisplayType type = self.currentRoom.currentDisplayType;
|
|
|
- if (type == DisplayAssistant) {
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(assistantDidDisplay)]) {
|
|
|
- [self.classroomDelegate assistantDidDisplay];
|
|
|
- }
|
|
|
- } else if (type == DisplayTeacher) {
|
|
|
+ if (type == DisplayTeacher) {
|
|
|
if ([self.classroomDelegate respondsToSelector:@selector(teacherDidDisplay)]) {
|
|
|
[self.classroomDelegate teacherDidDisplay];
|
|
|
}
|
|
@@ -887,112 +480,29 @@ isAudience:(BOOL)audience
|
|
|
}
|
|
|
|
|
|
- (void)onReceiveApplySpeechMessage:(ApplySpeechMessage *)msg {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- if (self.currentRoom.currentMember.role == RoleAssistant) {
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(upgradeDidApply:ticket:overMaxCount:)]) {
|
|
|
- RoomMember *mem = [self.currentRoom getMember:msg.requestUserId];
|
|
|
- if(!mem) {
|
|
|
- mem = [[RoomMember alloc] init];
|
|
|
- mem.userId = msg.requestUserId;
|
|
|
- mem.name = msg.requestUserName;
|
|
|
- }
|
|
|
- BOOL isMaxCount = [self.currentRoom getMemberCountWithoutAudience] >= 16 ? YES : NO;
|
|
|
- [self.classroomDelegate upgradeDidApply:mem ticket:msg.ticket overMaxCount:isMaxCount];
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
- (void)onReceiveSpeechResultMessage:(ApplySpeechResultMessage *)msg {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- if (msg.action == SpeechResultApprove) {
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(applyDidApprove)]) {
|
|
|
- [self.classroomDelegate applyDidApprove];
|
|
|
- }
|
|
|
- } else if (msg.action == SpeechResultReject) {
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(applyDidReject)]) {
|
|
|
- [self.classroomDelegate applyDidReject];
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
- (void)onReceiveTurnPageMessage:(TurnPageMessage *)msg {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
-
|
|
|
- });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)onReceiveRoleChangedMessage:(RoleChangedMessage *)msg {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- for(NSDictionary *dic in msg.users) {
|
|
|
- NSString *userId = dic[@"userId"];
|
|
|
- Role role = (Role)[dic[@"role"] intValue];
|
|
|
- if([self.classroomDelegate respondsToSelector:@selector(roleDidChange:forUser:)]) {
|
|
|
- [self.currentRoom updateMemeber:userId forRole:role];
|
|
|
- [self.classroomDelegate roleDidChange:role forUser:[self.currentRoom getMember:userId]];
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)onReceiveAssistantTransferMessage:(AssistantTransferMessage *)msg {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- if([self.classroomDelegate respondsToSelector:@selector(roleDidChange:forUser:)]) {
|
|
|
- [self.currentRoom updateMemeber:msg.toUserId forRole:RoleAssistant];
|
|
|
- [self.currentRoom updateMemeber:msg.operatorId forRole:RoleStudent];
|
|
|
- [self.classroomDelegate roleDidChange:RoleAssistant forUser:[self.currentRoom getMember:msg.toUserId]];
|
|
|
-// [self.classroomDelegate roleDidChange:RoleStudent forUser:[self.currentRoom getMember:msg.operatorId]];
|
|
|
- }
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(assistantDidTransfer:newAssistant:)]){
|
|
|
- [self.classroomDelegate assistantDidTransfer:[self.currentRoom getMember:msg.operatorId] newAssistant:[self.currentRoom getMember:msg.toUserId]];
|
|
|
- }
|
|
|
- });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)onReceiveTicketExpiredMessage:(TicketExpiredMessage *)msg {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(ticketDidExpire:)]) {
|
|
|
- [self.classroomDelegate ticketDidExpire:msg.ticket];
|
|
|
- }
|
|
|
- });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)onReceiveInviteUpgradeMessage:(InviteUpgradeMessage *)msg {
|
|
|
- dispatch_main_async_safe(^{
|
|
|
- if (msg.action == InviteUpgradeActionInvite) {
|
|
|
- if (self.currentRoom.currentMember.role == RoleAudience) {
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(upgradeDidInvite:)]) {
|
|
|
- [self.classroomDelegate upgradeDidInvite:msg.ticket];
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (msg.action == InviteUpgradeActionApprove) {
|
|
|
- if (self.currentRoom.currentMember.role == RoleAssistant) {
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(inviteDidApprove:)]) {
|
|
|
- RoomMember *mem = [self.currentRoom getMember:msg.operatorId];
|
|
|
- if(!mem) {
|
|
|
- mem = [[RoomMember alloc] init];
|
|
|
- mem.userId = msg.operatorId;
|
|
|
- mem.name = msg.operatorName;
|
|
|
- }
|
|
|
- mem.role = msg.role;
|
|
|
- [self.classroomDelegate inviteDidApprove:mem];
|
|
|
- }
|
|
|
- }
|
|
|
- } else if (msg.action == InviteUpgradeActionReject) {
|
|
|
- if (self.currentRoom.currentMember.role == RoleAssistant) {
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(inviteDidReject:)]) {
|
|
|
- RoomMember *mem = [self.currentRoom getMember:msg.operatorId];
|
|
|
- if(!mem) {
|
|
|
- mem = [[RoomMember alloc] init];
|
|
|
- mem.userId = msg.operatorId;
|
|
|
- mem.name = msg.operatorName;
|
|
|
- }
|
|
|
- [self.classroomDelegate inviteDidReject:mem];
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- (void)onReceiveControlDeviceNotifyMessage:(ControlDeviceNotifyMessage *)msg {
|
|
@@ -1002,19 +512,9 @@ isAudience:(BOOL)audience
|
|
|
[self.classroomDelegate deviceDidInviteEnable:msg.type ticket:msg.ticket];
|
|
|
}
|
|
|
} else if (msg.action == ControlDeviceActionApprove) {
|
|
|
- if (self.currentRoom.currentMember.role == RoleAssistant) {
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(deviceInviteEnableDidApprove:type:)]) {
|
|
|
- RoomMember *mem = [self.currentRoom getMember:msg.opUserId];
|
|
|
- [self.classroomDelegate deviceInviteEnableDidApprove:mem type:msg.type];
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
} else if (msg.action == ControlDeviceActionReject) {
|
|
|
- if (self.currentRoom.currentMember.role == RoleAssistant) {
|
|
|
- if ([self.classroomDelegate respondsToSelector:@selector(deviceInviteEnableDidReject:type:)]) {
|
|
|
- RoomMember *mem = [self.currentRoom getMember:msg.opUserId];
|
|
|
- [self.classroomDelegate deviceInviteEnableDidReject:mem type:msg.type];
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
}
|