|
@@ -32,6 +32,7 @@ import com.yonge.cooleshow.biz.dal.enums.live.EAnchorStatus;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.live.EOnOffStatus;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.ImLiveBroadcastRoomMemberMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
|
|
|
+import com.yonge.cooleshow.biz.dal.redisson.RedissonMessageService;
|
|
|
import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.liveroom.ImLiveBroadcastRoomMemberWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.liveroom.LiveRoomWrapper;
|
|
@@ -134,6 +135,10 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
|
|
|
@Autowired
|
|
|
private ImGroupService imGroupService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RedissonMessageService redissonMessageService;
|
|
|
+
|
|
|
/**
|
|
|
* 生成房间UID
|
|
|
*
|
|
@@ -1019,6 +1024,31 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public void setGroupMemberDefinedData(LiveRoomWrapper.LiveRoomVo roomVo, Integer onlineUser, Integer totalUser) {
|
|
|
+ List<TencentRequest.ChatRoomGroupDefinedData> appDefinedData = new ArrayList<>();
|
|
|
+ appDefinedData.add(TencentRequest.ChatRoomGroupDefinedData.builder()
|
|
|
+ .key(EGroupDefinedDataType.MEMBER_ONLINE.getCode())
|
|
|
+ .value(onlineUser.toString())
|
|
|
+ .build());
|
|
|
+ appDefinedData.add(TencentRequest.ChatRoomGroupDefinedData.builder()
|
|
|
+ .key(EGroupDefinedDataType.MEMBER_TOTAL.getCode())
|
|
|
+ .value(totalUser.toString())
|
|
|
+ .build());
|
|
|
+ try {
|
|
|
+ livePluginContext.getPluginService(roomVo.getServiceProvider())
|
|
|
+ .chatRoomGroupDefinedData(TencentRequest.ChatRoomGroup.builder()
|
|
|
+ .groupId(roomVo.getRoomUid())
|
|
|
+ .appDefinedData(appDefinedData)
|
|
|
+ .build());
|
|
|
+ log.info("设置直播群观看人数 roomUid:{}, data {}",roomVo.getRoomUid(), JSONObject.toJSONString(appDefinedData));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设置直播群观看人数失败", e);
|
|
|
+ throw new BizException("设置直播群观看人数失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 观看者-进入房间
|
|
|
*
|
|
@@ -1133,6 +1163,13 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
log.info(" sendOnlineUserCount>>>> param is null roomUid: {} fromUserId:{} count:{}", roomUid, fromUserId, count);
|
|
|
return;
|
|
|
}
|
|
|
+ // 缓存JoinRoom用户信息到redis
|
|
|
+ RBucket<Object> bucket = redissonClient.getBucket(RedissonMessageService.LIVE_ROOM_MEMBER + roomUid);
|
|
|
+ if (!bucket.isExists()) {
|
|
|
+ bucket.set(0, 30, TimeUnit.MINUTES);
|
|
|
+ // 发布删除缓存消息
|
|
|
+ redissonMessageService.publish(RedissonMessageService.TOPIC_MESSAGE, roomUid);
|
|
|
+ }
|
|
|
ImRoomMessage message = new ImRoomMessage();
|
|
|
message.setObjectName(ImRoomMessage.MEMBER_COUNT);
|
|
|
message.setClientType(ClientEnum.TEACHER.getCode());
|
|
@@ -1197,9 +1234,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
private LiveRoomMessage.MessageContent getMessageContent(ImRoomMessage message) {
|
|
|
|
|
|
switch (message.getObjectName()) {
|
|
|
- case LiveRoomMessage.FORCED_OFFLINE:
|
|
|
- return LiveRoomMessage.MessageContent.builder()
|
|
|
- .build();
|
|
|
+
|
|
|
case LiveRoomMessage.LOOKER_LOGIN_OUT:
|
|
|
return LiveRoomMessage.MessageContent.builder()
|
|
|
.targetId( imGroupService.getImUserId(message.getFromUserId(),message.getClientType()))
|
|
@@ -1212,9 +1247,8 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
.viewers(liveRoomVo.getTotalLookNum().longValue())
|
|
|
.likes(liveRoomVo.getLikeNum().longValue())
|
|
|
.build();
|
|
|
+ case LiveRoomMessage.FORCED_OFFLINE:
|
|
|
case LiveRoomMessage.WELCOME:
|
|
|
- return LiveRoomMessage.MessageContent.builder()
|
|
|
- .build();
|
|
|
default:
|
|
|
return LiveRoomMessage.MessageContent.builder()
|
|
|
.build();
|
|
@@ -1999,6 +2033,15 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
|
|
|
} else {
|
|
|
roomVo.setVideoNum(0);
|
|
|
}
|
|
|
+
|
|
|
+ // 直播间主讲人信息
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(roomVo.getSpeakerId());
|
|
|
+ if (sysUser !=null) {
|
|
|
+ roomVo.setSpeakerName(sysUser.getRealName());
|
|
|
+ roomVo.setSpeakerPic(sysUser.getAvatar());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return roomVo;
|
|
|
}
|
|
|
|