|
@@ -253,7 +253,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
this.save(room);
|
|
|
log.info("createTempLiveRoom>>>>>>room:{}", room.getRoomUid());
|
|
|
//去融云创建房间及创建房间缓存信息
|
|
|
- createLiveRoomInfo(room, sysUser);
|
|
|
+ this.createLiveRoomInfo(room, sysUser);
|
|
|
return roomUid;
|
|
|
}
|
|
|
|
|
@@ -263,15 +263,15 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
private void createLiveRoomInfo(LiveRoom room) {
|
|
|
//查询主讲人信息
|
|
|
SysUser sysUser = getSysUser(room.getSpeakerId());
|
|
|
- createLiveRoomInfo(room, sysUser);
|
|
|
+ this.createLiveRoomInfo(room, sysUser);
|
|
|
}
|
|
|
|
|
|
private void createLiveRoomInfo(LiveRoom room, SysUser sysUser) {
|
|
|
try {
|
|
|
//生成主讲人信息
|
|
|
- createRoomInfoCache(room, sysUser);
|
|
|
+ this.createRoomInfoCache(room, sysUser);
|
|
|
//去融云创建房间
|
|
|
- createLiveRoom(room.getRoomUid(), room.getRoomTitle());
|
|
|
+ this.createLiveRoom(room.getRoomUid(), room.getRoomTitle());
|
|
|
} catch (Exception e) {
|
|
|
throw new BizException("创建直播间失败!", e.getCause());
|
|
|
}
|
|
@@ -352,7 +352,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
}
|
|
|
//当前时间 大于 直播间过期时间
|
|
|
if (now.getTime() >= expiredDate.getTime()) {
|
|
|
- destroyLiveRoom(room);
|
|
|
+ this.destroyLiveRoom(room);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -366,7 +366,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void destroyLiveRoom(String roomUId) {
|
|
|
LiveRoom liveRoom = this.getOne(Wrappers.<LiveRoom>lambdaQuery().eq(LiveRoom::getRoomUid, roomUId));
|
|
|
- destroyLiveRoom(liveRoom);
|
|
|
+ this.destroyLiveRoom(liveRoom);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -394,10 +394,23 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
});
|
|
|
}
|
|
|
//删除房间
|
|
|
- ImDestroyLiveRoom(room.getRoomUid());
|
|
|
+ this.ImDestroyLiveRoom(room.getRoomUid());
|
|
|
//修改房间状态
|
|
|
room.setLiveState(2);
|
|
|
this.updateById(room);
|
|
|
+ String speakerIdStr = room.getSpeakerId().toString();
|
|
|
+ //关闭直播间发送消息
|
|
|
+ ImRoomMessage message = new ImRoomMessage();
|
|
|
+ message.setFromUserId(speakerIdStr);
|
|
|
+ message.setToChatroomId(room.getRoomUid());
|
|
|
+ message.setObjectName(ImRoomMessage.FORCED_OFFLINE);
|
|
|
+ message.setContent(speakerIdStr);
|
|
|
+ try {
|
|
|
+ this.publishRoomMessage(message);
|
|
|
+ log.info("destroyLiveRoom>>>> FORCED_OFFLINE : {}", speakerIdStr);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("destroyLiveRoom>>>> FORCED_OFFLINE {}", e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -507,7 +520,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
message.setObjectName(ImRoomMessage.RC_CHATROOM_LEAVE);
|
|
|
message.setContent(userId);
|
|
|
try {
|
|
|
- publishRoomMessage(message);
|
|
|
+ this.publishRoomMessage(message);
|
|
|
log.info("opsRoom>>>> looker RC_CHATROOM_LEAVE : {}", userJsonStr);
|
|
|
} catch (Exception e) {
|
|
|
log.error("opsRoom>>>> looker error RC_CHATROOM_LEAVE {}", e.getMessage());
|
|
@@ -542,7 +555,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
}
|
|
|
//查询老师是否有进入过放假,没有则写老师考勤表的进入时间
|
|
|
if (Objects.isNull(teacherAttendance)) {
|
|
|
- setTeacherAttendance(Long.parseLong(userIdStr), roomInfo.getCourseGroupId(), roomInfo.getCourseId());
|
|
|
+ this.setTeacherAttendance(Long.parseLong(userIdStr), roomInfo.getCourseGroupId(), roomInfo.getCourseId());
|
|
|
}
|
|
|
roomInfoCache.set(roomInfo);
|
|
|
log.info("opsRoom>>>> join speakerCache {}", JSONObject.toJSONString(roomInfo));
|
|
@@ -616,12 +629,12 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
* @param roomUid 房间uid
|
|
|
*/
|
|
|
public RoomInfoCache speakerJoinRoom(String roomUid) {
|
|
|
- RoomInfoCache roomInfo = speakerCheckRoomInfo(roomUid);
|
|
|
+ RoomInfoCache roomInfo = this.speakerCheckRoomInfo(roomUid);
|
|
|
Date now = new Date();
|
|
|
roomInfo.setSpeakerState(0);
|
|
|
roomInfo.setJoinRoomTime(now);
|
|
|
//查询老师是否有进入过,没有则写老师考勤表的进入时间
|
|
|
- setTeacherAttendance(roomInfo.getSpeakerId(), roomInfo.getCourseGroupId(), roomInfo.getCourseId());
|
|
|
+ this.setTeacherAttendance(roomInfo.getSpeakerId(), roomInfo.getCourseGroupId(), roomInfo.getCourseId());
|
|
|
//记录当前用户对应的房间uid
|
|
|
redissonClient.getBucket(LIVE_USER_ROOM.replace(USER_ID, roomInfo.getSpeakerId().toString())).set(roomUid, 2L, TimeUnit.DAYS);
|
|
|
return roomInfo;
|
|
@@ -635,12 +648,12 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
*/
|
|
|
public RoomInfoCache joinRoom(String roomUid, Long userId) {
|
|
|
//获取进入房间人员信息
|
|
|
- SysUser sysUser = getSysUser(userId);
|
|
|
+ SysUser sysUser = this.getSysUser(userId);
|
|
|
//校验信息
|
|
|
- RoomInfoCache roomInfo = checkStudentRoom(roomUid, sysUser);
|
|
|
+ RoomInfoCache roomInfo = this.checkStudentRoom(roomUid, sysUser);
|
|
|
Date now = new Date();
|
|
|
//房间累计用户信息-指只要进入到该房间的用户都要记录
|
|
|
- RMap<Long, String> roomTotalUser = getTotalUserCache(roomUid);
|
|
|
+ RMap<Long, String> roomTotalUser = this.getTotalUserCache(roomUid);
|
|
|
//判断是否第一次进房间
|
|
|
RoomUserInfoCache userInfo;
|
|
|
if (roomTotalUser.containsKey(userId)) {
|
|
@@ -653,7 +666,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
userInfo.setUserName(sysUser.getRealName());
|
|
|
userInfo.setFirstJoinTime(now);
|
|
|
//查询学生是否有进入过,没有则写学生考勤表的进入时间
|
|
|
- setStudentAttendance(userId, roomInfo.getCourseGroupId(), roomInfo.getCourseId());
|
|
|
+ this.setStudentAttendance(userId, roomInfo.getCourseGroupId(), roomInfo.getCourseId());
|
|
|
}
|
|
|
userInfo.setDynamicJoinTime(now);
|
|
|
//用户json信息
|
|
@@ -661,7 +674,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
//写入人员缓存
|
|
|
roomTotalUser.fastPut(userId, userJsonStr);
|
|
|
//写入在线人员缓存
|
|
|
- RMap<Long, String> onlineUserCache = getOnlineUserCache(roomUid);
|
|
|
+ RMap<Long, String> onlineUserCache = this.getOnlineUserCache(roomUid);
|
|
|
onlineUserCache.fastPut(userId, userJsonStr);
|
|
|
log.info("joinRoom>>>> userInfo: {}", userJsonStr);
|
|
|
//向直播间发送当前在线人数消息
|
|
@@ -782,7 +795,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
message.setContent(sendMap);
|
|
|
//发送消息
|
|
|
try {
|
|
|
- publishRoomMessage(message);
|
|
|
+ this.publishRoomMessage(message);
|
|
|
log.info("sendOnlineUserCount>>>> message: {}", JSONObject.toJSONString(message));
|
|
|
} catch (Exception e) {
|
|
|
log.error("sendOnlineUserCount>>>> error {}", e.getMessage());
|