|
@@ -731,8 +731,8 @@ public class RoomServiceImpl implements RoomService {
|
|
|
roomMember = saveRoomMember(roomId, userId);
|
|
|
}
|
|
|
String joinSuccessKey = "joinRoomSuccess" + roomId + userId;
|
|
|
- Boolean aBoolean = redisTemplate.opsForValue().setIfAbsent(joinSuccessKey, roomId, 1L, TimeUnit.SECONDS);
|
|
|
- if (!aBoolean) {
|
|
|
+ Boolean exist = redisTemplate.opsForValue().setIfAbsent(joinSuccessKey, roomId, 1L, TimeUnit.SECONDS);
|
|
|
+ if (Boolean.FALSE.equals(exist)) {
|
|
|
RoleEnum roleEnum = RoleEnum.getEnumByValue(roomMember.getRole());
|
|
|
if (roleEnum == RoleTeacher && StringUtils.isNotEmpty(deviceNum)) {
|
|
|
teacherAttendanceService.updateDeviceNum(Integer.parseInt(roomId.substring(1)), userId, deviceNum, null);
|
|
@@ -744,99 +744,104 @@ public class RoomServiceImpl implements RoomService {
|
|
|
RoleEnum roleEnum = RoleEnum.getEnumByValue(roomMember.getRole());
|
|
|
CourseSchedule schedule = courseScheduleDao.getLock(Long.parseLong(roomId.substring(1)));
|
|
|
|
|
|
- String display = "";
|
|
|
- if (roleEnum == RoleTeacher) {
|
|
|
- //如果是老师加入房间,调整节拍器状态
|
|
|
- courseScheduleStudentPaymentDao.adjustPlayMidi(schedule.getId(), null, null);
|
|
|
- display = "display://type=1?userId=" + userId + "?uri=";
|
|
|
- } else if (roleEnum == RoleEnum.RoleAssistant) {
|
|
|
- display = "display://type=0?userId=" + userId + "?uri=";
|
|
|
- }
|
|
|
- Date curTime = DateTimeUtils.currentUTC();
|
|
|
- Room room = roomDao.findByRid(roomId);
|
|
|
- log.info("joinRoomSuccess: roomId={}, userId={}, roleEnum={}, room={}", roomId, userId, roleEnum.name(), Objects.isNull(room));
|
|
|
- if (room == null) {
|
|
|
- saveRoom(roomId, roomId, curTime, display);
|
|
|
- this.joinImGroup(roomId, schedule.getActualTeacherId(), schedule);
|
|
|
- } else {
|
|
|
- if (roleEnum == RoleTeacher || roleEnum == RoleEnum.RoleAssistant) {
|
|
|
- updateDisplay(roomId, userId, display, 0);
|
|
|
- }
|
|
|
- }
|
|
|
+ // 非直播课执行流程;VIP课、网管课
|
|
|
+ if (GroupType.LIVE != schedule.getGroupType()) {
|
|
|
|
|
|
- UserInfo userInfo = userDao.findByUid(userId);
|
|
|
- if (userInfo == null) {
|
|
|
- userInfo = new UserInfo();
|
|
|
- userInfo.setUid(userId);
|
|
|
- userInfo.setName(roomMember.getName());
|
|
|
- userInfo.setCreateDt(curTime);
|
|
|
- userInfo.setUpdateDt(curTime);
|
|
|
- userDao.save(userInfo);
|
|
|
- }
|
|
|
- MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Join, userId, roleEnum.getValue());
|
|
|
- msg.setTimestamp(curTime);
|
|
|
- msg.setUserName(roomMember.getName());
|
|
|
- msg.setCamera(true);
|
|
|
- Boolean playMidi = false;
|
|
|
- Boolean examSong = false;
|
|
|
- if (roleEnum == RoleStudent) {
|
|
|
- String midiByCourseIdAndUserId = courseScheduleStudentPaymentDao.getMidiByCourseIdAndUserId(schedule.getId().toString(), userId);
|
|
|
- //获取节拍器信息
|
|
|
- if (StringUtils.isNotEmpty(midiByCourseIdAndUserId)) {
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(midiByCourseIdAndUserId);
|
|
|
- if (jsonObject.get("enable") != null) {
|
|
|
- playMidi = Boolean.parseBoolean(jsonObject.get("enable").toString());
|
|
|
+ String display = "";
|
|
|
+ if (roleEnum == RoleTeacher) {
|
|
|
+ //如果是老师加入房间,调整节拍器状态
|
|
|
+ courseScheduleStudentPaymentDao.adjustPlayMidi(schedule.getId(), null, null);
|
|
|
+ display = "display://type=1?userId=" + userId + "?uri=";
|
|
|
+ } else if (roleEnum == RoleEnum.RoleAssistant) {
|
|
|
+ display = "display://type=0?userId=" + userId + "?uri=";
|
|
|
+ }
|
|
|
+ Date curTime = DateTimeUtils.currentUTC();
|
|
|
+ Room room = roomDao.findByRid(roomId);
|
|
|
+ log.info("joinRoomSuccess: roomId={}, userId={}, roleEnum={}, room={}", roomId, userId, roleEnum.name(), Objects.isNull(room));
|
|
|
+ if (room == null) {
|
|
|
+ saveRoom(roomId, roomId, curTime, display);
|
|
|
+ this.joinImGroup(roomId, schedule.getActualTeacherId(), schedule);
|
|
|
+ } else {
|
|
|
+ if (roleEnum == RoleTeacher || roleEnum == RoleEnum.RoleAssistant) {
|
|
|
+ updateDisplay(roomId, userId, display, 0);
|
|
|
}
|
|
|
}
|
|
|
- String examJson = courseScheduleStudentPaymentDao.getExamJsonByCourseIdAndUserId(schedule.getId(), Integer.parseInt(userId));
|
|
|
- if (StringUtils.isNotEmpty(examJson)) {
|
|
|
- ExamSongDownloadData examSongDownloadData = JSON.parseObject(examJson, ExamSongDownloadData.class);
|
|
|
- examSong = examSongDownloadData.getEnable();
|
|
|
+
|
|
|
+ UserInfo userInfo = userDao.findByUid(userId);
|
|
|
+ if (userInfo == null) {
|
|
|
+ userInfo = new UserInfo();
|
|
|
+ userInfo.setUid(userId);
|
|
|
+ userInfo.setName(roomMember.getName());
|
|
|
+ userInfo.setCreateDt(curTime);
|
|
|
+ userInfo.setUpdateDt(curTime);
|
|
|
+ userDao.save(userInfo);
|
|
|
}
|
|
|
- }
|
|
|
- msg.setHandUpOn(roomMember.isHand());
|
|
|
- msg.setMetronomeSwitch(playMidi);
|
|
|
- msg.setExamSongSwitch(examSong);
|
|
|
+ MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Join, userId, roleEnum.getValue());
|
|
|
+ msg.setTimestamp(curTime);
|
|
|
+ msg.setUserName(roomMember.getName());
|
|
|
+ msg.setCamera(true);
|
|
|
+ Boolean playMidi = false;
|
|
|
+ Boolean examSong = false;
|
|
|
+ if (roleEnum == RoleStudent) {
|
|
|
+ String midiByCourseIdAndUserId = courseScheduleStudentPaymentDao.getMidiByCourseIdAndUserId(schedule.getId().toString(), userId);
|
|
|
+ //获取节拍器信息
|
|
|
+ if (StringUtils.isNotEmpty(midiByCourseIdAndUserId)) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(midiByCourseIdAndUserId);
|
|
|
+ if (jsonObject.get("enable") != null) {
|
|
|
+ playMidi = Boolean.parseBoolean(jsonObject.get("enable").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String examJson = courseScheduleStudentPaymentDao.getExamJsonByCourseIdAndUserId(schedule.getId(), Integer.parseInt(userId));
|
|
|
+ if (StringUtils.isNotEmpty(examJson)) {
|
|
|
+ ExamSongDownloadData examSongDownloadData = JSON.parseObject(examJson, ExamSongDownloadData.class);
|
|
|
+ examSong = examSongDownloadData.getEnable();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ msg.setHandUpOn(roomMember.isHand());
|
|
|
+ msg.setMetronomeSwitch(playMidi);
|
|
|
+ msg.setExamSongSwitch(examSong);
|
|
|
|
|
|
|
|
|
- // 获取RTC服务提供方
|
|
|
- String rtcServiceProvider = Optional.ofNullable(schedule.getServiceProvider()).orElse("rongCloud");
|
|
|
+ // 获取RTC服务提供方
|
|
|
+ String rtcServiceProvider = Optional.ofNullable(schedule.getServiceProvider()).orElse("rongCloud");
|
|
|
|
|
|
- RTCRoomPluginService pluginService = rtcRoomPluginContext.getPluginService(rtcServiceProvider);
|
|
|
- if (rtcServiceProvider.equals(TencentCloudRTCPlugin.PLUGIN_NAME)) {
|
|
|
- // 腾讯云RTC服务
|
|
|
- RTCRoomMessage.MessageContent.MessageContentBuilder action = RTCRoomMessage.MessageContent.builder()
|
|
|
- .action(EMemberAction.JOIN.getValue());
|
|
|
+ RTCRoomPluginService pluginService = rtcRoomPluginContext.getPluginService(rtcServiceProvider);
|
|
|
+ if (rtcServiceProvider.equals(TencentCloudRTCPlugin.PLUGIN_NAME)) {
|
|
|
+ // 腾讯云RTC服务
|
|
|
+ RTCRoomMessage.MessageContent.MessageContentBuilder action = RTCRoomMessage.MessageContent.builder()
|
|
|
+ .action(EMemberAction.JOIN.getValue());
|
|
|
|
|
|
- if (roleEnum == RoleTeacher) {
|
|
|
- action.role(roleEnum.getValue());
|
|
|
- } else {
|
|
|
- action.role(roleEnum.getValue());
|
|
|
- }
|
|
|
- action.handUpOn(roomMember.isHand())
|
|
|
- .microphone(roomMember.isMic())
|
|
|
- .timestamp(curTime.getTime())
|
|
|
- .camera(true)
|
|
|
- .sendUserInfo(getSendUser(userId,roleEnum));
|
|
|
-
|
|
|
- // 开启全员静音,重置学员状态
|
|
|
- if (schedule.getMuteAll()) {
|
|
|
- action.microphone(false);
|
|
|
- }
|
|
|
+ if (roleEnum == RoleTeacher) {
|
|
|
+ action.role(roleEnum.getValue());
|
|
|
+ } else {
|
|
|
+ action.role(roleEnum.getValue());
|
|
|
+ }
|
|
|
+ action.handUpOn(roomMember.isHand())
|
|
|
+ .microphone(roomMember.isMic())
|
|
|
+ .timestamp(curTime.getTime())
|
|
|
+ .camera(true)
|
|
|
+ .sendUserInfo(getSendUser(userId,roleEnum));
|
|
|
+
|
|
|
+ // 开启全员静音,重置学员状态
|
|
|
+ if (schedule.getMuteAll()) {
|
|
|
+ action.microphone(false);
|
|
|
+ }
|
|
|
|
|
|
- RTCRoomMessage roomMessage = RTCRoomMessage.builder()
|
|
|
- .objectName(RTCRoomMessage.MEMBER_CHANGE_MESSAGE)
|
|
|
- .fromUserId(userId)
|
|
|
- .content(action.build())
|
|
|
- .toChatRoomId(roomId)
|
|
|
- .isPersisted(1)
|
|
|
- .isIncludeSender(1)
|
|
|
- .build();
|
|
|
+ RTCRoomMessage roomMessage = RTCRoomMessage.builder()
|
|
|
+ .objectName(RTCRoomMessage.MEMBER_CHANGE_MESSAGE)
|
|
|
+ .fromUserId(userId)
|
|
|
+ .content(action.build())
|
|
|
+ .toChatRoomId(roomId)
|
|
|
+ .isPersisted(1)
|
|
|
+ .isIncludeSender(1)
|
|
|
+ .build();
|
|
|
|
|
|
- pluginService.sendChatRoomMessage(roomMessage);
|
|
|
- } else {
|
|
|
- imHelper.publishMessage(userId, roomId, msg);
|
|
|
+ pluginService.sendChatRoomMessage(roomMessage);
|
|
|
+ } else {
|
|
|
+ imHelper.publishMessage(userId, roomId, msg);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
log.info("join room success: roomId = {}, userId = {}, role = {}", roomId, userId, roleEnum);
|
|
|
signInSuccess(roomMember, deviceNum);
|
|
|
}
|
|
@@ -922,9 +927,9 @@ public class RoomServiceImpl implements RoomService {
|
|
|
}
|
|
|
|
|
|
String leaveSuccessKey = "leaveRoomSuccess" + roomId + userId;
|
|
|
- Boolean aBoolean = redisTemplate.opsForValue().setIfAbsent(leaveSuccessKey, roomId, 1L, TimeUnit.SECONDS);
|
|
|
- log.info("leaveRoomSuccess: roomId={}, userId={},deviceNum={},aBoolean={}", roomId, userId, deviceNum, aBoolean);
|
|
|
- if (Boolean.FALSE.equals(aBoolean)) {
|
|
|
+ Boolean exist = redisTemplate.opsForValue().setIfAbsent(leaveSuccessKey, roomId, 1L, TimeUnit.SECONDS);
|
|
|
+ log.info("leaveRoomSuccess: roomId={}, userId={},deviceNum={},aBoolean={}", roomId, userId, deviceNum, exist);
|
|
|
+ if (Boolean.FALSE.equals(exist)) {
|
|
|
if (StringUtils.isNotEmpty(deviceNum)) {
|
|
|
//如果设备号不为空,更新设备号
|
|
|
if (roleEnum == RoleTeacher) {
|