|
@@ -531,18 +531,40 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
}
|
|
}
|
|
log.info("sendLiveOnlineNum>>>> liveRooms{}", JSONObject.toJSONString(liveRooms));
|
|
log.info("sendLiveOnlineNum>>>> liveRooms{}", JSONObject.toJSONString(liveRooms));
|
|
liveRooms.forEach(room -> {
|
|
liveRooms.forEach(room -> {
|
|
|
|
+ //查询在线观看者信息
|
|
|
|
+ RMap<Integer, BaseRoomUserVo> onlineUserCache = this.getOnlineUserCache(room.getRoomUid());
|
|
|
|
+ if (!onlineUserCache.isExists()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
//发送消息到直播间
|
|
//发送消息到直播间
|
|
ImRoomMessage message = new ImRoomMessage();
|
|
ImRoomMessage message = new ImRoomMessage();
|
|
message.setFromUserId(room.getSpeakerId().toString());
|
|
message.setFromUserId(room.getSpeakerId().toString());
|
|
message.setToChatroomId(room.getRoomUid());
|
|
message.setToChatroomId(room.getRoomUid());
|
|
message.setObjectName(ImRoomMessage.MEMBER_COUNT);
|
|
message.setObjectName(ImRoomMessage.MEMBER_COUNT);
|
|
- message.setContent(getNum.apply(this::getOnlineUserCache, room.getRoomUid()));
|
|
|
|
|
|
+ int size = onlineUserCache.size();
|
|
|
|
+ if (size < 1) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ message.setContent(size);
|
|
|
|
+ //主讲人发送消息
|
|
|
|
+ try {
|
|
|
|
+ imFeignService.publishRoomMsg(message);
|
|
|
|
+ log.info("sendLiveOnlineNum>>>> speakerId room:{}", JSONObject.toJSONString(message));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("sendLiveOnlineNum>>>> speakerId error {}", e.getMessage());
|
|
|
|
+ log.error("sendLiveOnlineNum>>>> speakerId sendMessage {} :", JSONObject.toJSONString(message));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //主讲人自己发消息自己收不到,需要一个观看者发送消息
|
|
|
|
+ List<BaseRoomUserVo> collect = onlineUserCache.values().stream().limit(1).collect(Collectors.toList());
|
|
|
|
+ BaseRoomUserVo baseRoomUserVo = collect.get(0);
|
|
|
|
+ message.setFromUserId(baseRoomUserVo.getUserId().toString());
|
|
try {
|
|
try {
|
|
imFeignService.publishRoomMsg(message);
|
|
imFeignService.publishRoomMsg(message);
|
|
- log.info("sendLiveOnlineNum>>>> room:{}", JSONObject.toJSONString(message));
|
|
|
|
|
|
+ log.info("sendLiveOnlineNum>>>> looker room:{}", JSONObject.toJSONString(message));
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error("sendLiveOnlineNum>>>> error {}", e.getMessage());
|
|
|
|
- log.error("sendLiveOnlineNum>>>> sendMessage {} :", JSONObject.toJSONString(message));
|
|
|
|
|
|
+ log.error("sendLiveOnlineNum>>>> looker error {}", e.getMessage());
|
|
|
|
+ log.error("sendLiveOnlineNum>>>> looker sendMessage {} :", JSONObject.toJSONString(message));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|