|
@@ -980,7 +980,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
LiveRoomMessage message = LiveRoomMessage.builder()
|
|
|
.isIncludeSender(1)
|
|
|
.objectName(LiveRoomMessage.STAT_SYNC)
|
|
|
- .fromUserId(userid)
|
|
|
+ .fromUserId(roomVo.getSpeakerId().toString())
|
|
|
.toChatRoomId(roomVo.getRoomUid())
|
|
|
.content(messageContent)
|
|
|
.build();
|
|
@@ -1005,7 +1005,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
|
|
|
// 消息发送用户
|
|
|
LiveRoomMessage.MessageUser messageUser = null;
|
|
|
- SysUser sysUser = sysUserFeignService.queryUserInfo();
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(Integer.parseInt(userid));
|
|
|
if (Objects.nonNull(sysUser)) {
|
|
|
// 发送用户信息
|
|
|
messageUser = LiveRoomMessage.MessageUser
|
|
@@ -1024,18 +1024,20 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
|
|
|
LiveRoomMessage message = LiveRoomMessage.builder()
|
|
|
.isIncludeSender(1)
|
|
|
- .objectName(LiveRoomMessage.LOOKER_LOGIN_OUT)
|
|
|
- .fromUserId(userid)
|
|
|
+ .objectName(LiveRoomMessage.LEAVE)
|
|
|
+ .fromUserId(roomVo.getSpeakerId().toString())
|
|
|
.toChatRoomId(roomVo.getRoomUid())
|
|
|
.content(messageContent)
|
|
|
.build();
|
|
|
try {
|
|
|
- // TODO: 取消用户离开事件消息发送
|
|
|
+ // 黑名单才发送退出消息
|
|
|
//用户离开直播间发送退出房间消息给主讲人
|
|
|
- /*
|
|
|
+ if (!imLiveRoomBlackService.checkBlackUser(Integer.parseInt(userid), roomVo.getRoomUid())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
LivePluginService pluginService = livePluginContext.getPluginService(roomVo.getServiceProvider());
|
|
|
pluginService.sendChatRoomMessage(message);
|
|
|
- */
|
|
|
+
|
|
|
log.info("sendLiveRoomLoginOutMessage>>>> looker LOOKER_LOGIN_OUT : roomId={}, userId={}", roomVo.getRoomUid(), userid);
|
|
|
} catch (Exception e) {
|
|
|
log.error("sendLiveRoomLoginOutMessage>>>> looker error LOOKER_LOGIN_OUT {}", e.getMessage());
|
|
@@ -1091,7 +1093,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
LiveRoomMessage message = LiveRoomMessage.builder()
|
|
|
.isIncludeSender(1)
|
|
|
.objectName(LiveRoomMessage.MEMBER_COUNT)
|
|
|
- .fromUserId(fromUserId.toString())
|
|
|
+ .fromUserId(roomVo.getSpeakerId().toString())
|
|
|
.toChatRoomId(roomUid)
|
|
|
.content(messageContent)
|
|
|
.build();
|
|
@@ -1345,11 +1347,69 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
onlineUserInfo.fastPut(userId, JSONObject.toJSONString(userInfo));
|
|
|
//向直播间发送当前在线人数消息
|
|
|
this.sendOnlineUserCount(imLiveBroadcastRoomVo, userId, onlineUserInfo.size());
|
|
|
+
|
|
|
+ // 黑名单发送进入消息
|
|
|
+ if (imLiveRoomBlackService.checkBlackUser(userId, imLiveBroadcastRoomVo.getRoomUid())) {
|
|
|
+ // 发送进入消息
|
|
|
+ this.sendBlackJoinRoom(userId, imLiveBroadcastRoomVo);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
log.info("join sendOnlineUserCount>>>> roomUid: {} fromUserId:{} count:{}", roomUid, userId, onlineUserInfo.size());
|
|
|
log.info("joinRoom>>>> userInfo: {}", JSONObject.toJSONString(userInfo));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 发送黑名单进入消息
|
|
|
+ * @param userId 用户id
|
|
|
+ */
|
|
|
+ private void sendBlackJoinRoom(Integer userId,ImLiveBroadcastRoomVo roomVo) {
|
|
|
+
|
|
|
+ String roomUid = roomVo.getRoomUid();
|
|
|
+ //校验传入参数,房间uid和发送人id不能为空
|
|
|
+ if (!WrapperUtil.checkObj(roomUid, userId)) {
|
|
|
+ log.info(" sendOnlineUserCount>>>> param is null roomUid: {} fromUserId:{} ", roomUid, userId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 消息发送用户
|
|
|
+ LiveRoomMessage.MessageUser messageUser = null;
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(userId);
|
|
|
+ if (Objects.nonNull(sysUser)) {
|
|
|
+ // 发送用户信息
|
|
|
+ messageUser = LiveRoomMessage.MessageUser
|
|
|
+ .builder()
|
|
|
+ .sendUserId(sysUser.getId().toString())
|
|
|
+ .sendUserName(sysUser.getUsername())
|
|
|
+ .avatarUrl(sysUser.getAvatar())
|
|
|
+ .blackFlag(true)
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ LiveRoomMessage.MessageContent messageContent = LiveRoomMessage.MessageContent
|
|
|
+ .builder()
|
|
|
+ .sendUserInfo(messageUser)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ LiveRoomMessage message = LiveRoomMessage.builder()
|
|
|
+ .isIncludeSender(1)
|
|
|
+ .objectName(LiveRoomMessage.WELCOME)
|
|
|
+ .fromUserId(roomVo.getSpeakerId().toString())
|
|
|
+ .toChatRoomId(roomUid)
|
|
|
+ .content(messageContent)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ //发送消息
|
|
|
+ try {
|
|
|
+ livePluginContext.getPluginService(roomVo.getServiceProvider()).sendChatRoomMessage(message);
|
|
|
+ log.info("sendBlackJoinRoom>>>> message: {}", JSONObject.toJSONString(message));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("sendBlackJoinRoom>>>> error {}", e.getMessage());
|
|
|
+ log.error("sendBlackJoinRoom>>>> sendMessage {} :", JSONObject.toJSONString(message));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取直播间用户信息
|
|
|
* @param userId 用户id
|
|
|
* @param imLiveBroadcastRoomVo 直播间信息
|
|
@@ -1640,6 +1700,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
// 创建直播间IM群
|
|
|
pluginService.chatRoomCreate(room.getRoomUid(), room.getRoomTitle(),sysUser.getId().toString());
|
|
|
|
|
|
+ createSpeakerInfo(room, sysUser);
|
|
|
Boolean whetherVideoFlag = getRoomConfig(room.getRoomConfig()).map(o -> o.getWhether_video() == 0).orElse(true);
|
|
|
|
|
|
// 腾讯云直播,提前生成录制规则
|
|
@@ -1731,7 +1792,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
case ANCHOR_CAMERA:
|
|
|
appDefinedData.add(TencentRequest.ChatRoomGroupDefinedData.builder()
|
|
|
.key(key.getCode())
|
|
|
- .value("OFF")
|
|
|
+ .value("ON")
|
|
|
.build());
|
|
|
break;
|
|
|
}
|
|
@@ -2131,6 +2192,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
if (liveRoom.getCameraStatus() != null) {
|
|
|
setGroupDefinedData(room,EGroupDefinedDataType.ANCHOR_CAMERA,liveRoom.getCameraStatus() == 1?
|
|
|
EOnOffStatus.ON.getCode():EOnOffStatus.OFF.getCode());
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
return this.updateById(imLiveBroadcastRoom);
|
|
@@ -2276,15 +2338,24 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
LivePluginService pluginService = livePluginContext.getPluginService(
|
|
|
imLiveBroadcastRoom.getServiceProvider());
|
|
|
try {
|
|
|
- TencentWrapper.LiveStreamState liveStreamState = pluginService
|
|
|
- .liveStreamState(getStreamId(imLiveBroadcastRoom.getRoomUid(),imLiveBroadcastRoom.getSpeakerId()));
|
|
|
- if (liveStreamState == null) {
|
|
|
- log.error("查询直播间流失败,返回结果为空");
|
|
|
+ if (pluginService == null) {
|
|
|
+ log.error("查询直播间流失败,未找到对应的插件");
|
|
|
continue;
|
|
|
}
|
|
|
- log.info("查询直播间流状态:{},roomUid:{}", JSON.toJSONString(liveStreamState), imLiveBroadcastRoom.getRoomUid());
|
|
|
- if (!"active".equals(liveStreamState.getStreamState())) {
|
|
|
- roomDestroy(imLiveBroadcastRoom.getRoomUid());
|
|
|
+ if (pluginService.pluginName().equals(TencentCloudLivePlugin.PLUGIN_NAME)) {
|
|
|
+ TencentWrapper.LiveStreamState liveStreamState = pluginService.liveStreamState(
|
|
|
+ getStreamId(imLiveBroadcastRoom.getRoomUid(), imLiveBroadcastRoom.getSpeakerId()));
|
|
|
+ if (liveStreamState == null) {
|
|
|
+ log.error("查询直播间流失败,返回结果为空");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ log.info("查询直播间流状态:{},roomUid:{}", JSON.toJSONString(liveStreamState), imLiveBroadcastRoom.getRoomUid());
|
|
|
+ if (!"active".equals(liveStreamState.getStreamState())) {
|
|
|
+ roomDestroy(imLiveBroadcastRoom.getRoomUid());
|
|
|
+ }
|
|
|
+ } else if (pluginService.pluginName().equals(RongCloudLivePlugin.PLUGIN_NAME)) {
|
|
|
+ // 融云走原有逻辑
|
|
|
+ destroyExpiredLiveRoom(new Date(), imLiveBroadcastRoom, 0);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
|