|
@@ -6,8 +6,11 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.microsvc.toolkit.middleware.rtc.RTCRoomPluginContext;
|
|
|
import com.microsvc.toolkit.middleware.rtc.RTCRoomPluginService;
|
|
|
+import com.microsvc.toolkit.middleware.rtc.enums.EMemberAction;
|
|
|
+import com.microsvc.toolkit.middleware.rtc.enums.EMemberRole;
|
|
|
import com.microsvc.toolkit.middleware.rtc.impl.TencentCloudRTCPlugin;
|
|
|
import com.microsvc.toolkit.middleware.rtc.message.ImGroupMemberWrapper;
|
|
|
+import com.microsvc.toolkit.middleware.rtc.message.RTCRoomMessage;
|
|
|
import com.ym.common.ApiException;
|
|
|
import com.ym.common.BaseResponse;
|
|
|
import com.ym.common.DisplayEnum;
|
|
@@ -527,7 +530,41 @@ public class RoomServiceImpl implements RoomService {
|
|
|
msg.setHandUpOn(roomMember.isHand());
|
|
|
msg.setMetronomeSwitch(playMidi);
|
|
|
msg.setExamSongSwitch(examSong);
|
|
|
- imHelper.publishMessage(userId, roomId, msg);
|
|
|
+
|
|
|
+
|
|
|
+ // 获取RTC服务提供方
|
|
|
+ String rtcServiceProvider = Optional.ofNullable(sysConfigDao.findConfigValue("rtc_service_provider")).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());
|
|
|
+
|
|
|
+ if (roleEnum == RoleTeacher) {
|
|
|
+ action.role(EMemberRole.TEACHER.getValue());
|
|
|
+ } else {
|
|
|
+ action.role(EMemberRole.STUDENT.getValue());
|
|
|
+ }
|
|
|
+ action.handUpOn(roomMember.isHand())
|
|
|
+ .microphone(playMidi)
|
|
|
+ .camera(true)
|
|
|
+ .sendUserInfo(RTCRoomMessage.MessageUser.builder()
|
|
|
+ .sendUserId(userId)
|
|
|
+ .sendUserName(userInfo.getName())
|
|
|
+ .avatarUrl(roomMember.getHeadUrl())
|
|
|
+ .build());
|
|
|
+
|
|
|
+
|
|
|
+ RTCRoomMessage roomMessage = RTCRoomMessage.builder()
|
|
|
+ .objectName(RTCRoomMessage.MEMBER_CHANGE_MESSAGE)
|
|
|
+ .content(action.build())
|
|
|
+ .build();
|
|
|
+
|
|
|
+ pluginService.sendChatRoomMessage(roomMessage);
|
|
|
+ } else {
|
|
|
+ imHelper.publishMessage(userId, roomId, msg);
|
|
|
+ }
|
|
|
log.info("join room success: roomId = {}, userId = {}, role = {}", roomId, userId, roleEnum);
|
|
|
signInSuccess(roomMember, deviceNum);
|
|
|
}
|
|
@@ -640,10 +677,43 @@ public class RoomServiceImpl implements RoomService {
|
|
|
log.info("leaveRoomSuccess dismiss the room: {},userId: {}", roomId, userId);
|
|
|
} else {
|
|
|
roomMemberDao.deleteUserByRidAndUid(roomId, userId);
|
|
|
- MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Leave, userId, roleEnum.getValue());
|
|
|
- msg.setUserName(username);
|
|
|
- imHelper.publishMessage(userId, roomId, msg);
|
|
|
+
|
|
|
+ // 获取RTC服务提供方
|
|
|
+ String rtcServiceProvider = Optional.ofNullable(sysConfigDao.findConfigValue("rtc_service_provider")).orElse("rongCloud");
|
|
|
+
|
|
|
+ RTCRoomPluginService pluginService = rtcRoomPluginContext.getPluginService(rtcServiceProvider);
|
|
|
+ if (rtcServiceProvider.equals(TencentCloudRTCPlugin.PLUGIN_NAME)) {
|
|
|
+ // 腾讯云RTC服务
|
|
|
+ RTCRoomMessage.MessageContent.MessageContentBuilder action = RTCRoomMessage.MessageContent.builder()
|
|
|
+ .action(EMemberAction.LEAVE.getValue());
|
|
|
+
|
|
|
+ if (roleEnum == RoleTeacher) {
|
|
|
+ action.role(EMemberRole.TEACHER.getValue());
|
|
|
+ } else {
|
|
|
+ action.role(EMemberRole.STUDENT.getValue());
|
|
|
+ }
|
|
|
+ action.handUpOn(false)
|
|
|
+ .microphone(false)
|
|
|
+ .camera(false).sendUserInfo(RTCRoomMessage.MessageUser.builder()
|
|
|
+ .sendUserId(userId)
|
|
|
+ .sendUserName(username)
|
|
|
+ .avatarUrl(sysUser.getAvatar())
|
|
|
+ .build());
|
|
|
+
|
|
|
+
|
|
|
+ RTCRoomMessage roomMessage = RTCRoomMessage.builder()
|
|
|
+ .objectName(RTCRoomMessage.MEMBER_CHANGE_MESSAGE)
|
|
|
+ .content(action.build())
|
|
|
+ .build();
|
|
|
+
|
|
|
+ pluginService.sendChatRoomMessage(roomMessage);
|
|
|
+ } else {
|
|
|
+ MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Leave, userId, roleEnum.getValue());
|
|
|
+ msg.setUserName(username);
|
|
|
+ imHelper.publishMessage(userId, roomId, msg);
|
|
|
// imHelper.quit(new String[]{userId}, roomId);
|
|
|
+ }
|
|
|
+
|
|
|
log.info("leaveRoomSuccess quit group: roomId={},userId: {}", roomId, userId);
|
|
|
}
|
|
|
userDao.deleteByUid(userId);
|