diff --git a/src/main/java/cn/com/tenlion/usercenter/service/huaweirtc/impl/HuaweiRtcServiceImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/huaweirtc/impl/HuaweiRtcServiceImpl.java index 562a463..c3883d3 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/huaweirtc/impl/HuaweiRtcServiceImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/huaweirtc/impl/HuaweiRtcServiceImpl.java @@ -9,6 +9,9 @@ import ink.wgink.module.instantmessage.websocket.pojo.WebSocketClientMessage; import ink.wgink.pojo.session.WebSocketSession; import org.springframework.stereotype.Service; +import java.util.Arrays; +import java.util.List; + /** * @ClassName: VideoCallServiceImpl * @Description: 视频通话 @@ -21,12 +24,14 @@ public class HuaweiRtcServiceImpl implements IHuaweiRtcService { @Override public void rtcCall(WebSocketClientMessage webSocketClientMessage) throws UserOfflineException { - String receiverUserId = webSocketClientMessage.getTo(); - WebSocketSession onlineUser = WebSocketChannelManager.getInstance().getOnlineUser(receiverUserId, ISmartCityUserCenterConsts.APP_CLIENT_NAME); - if (onlineUser == null) { - throw new RtcUserOfflineException("用户不在线"); + List receiverUserIds = Arrays.asList(webSocketClientMessage.getTo().split(",")); + List onlineUsers = WebSocketChannelManager.getInstance().listOnlineUser(receiverUserIds, ISmartCityUserCenterConsts.APP_CLIENT_NAME); + if (onlineUsers.isEmpty()) { + throw new RtcUserOfflineException("没有在线用户"); } - WebSocketChannelManager.getInstance().sendText(onlineUser.getChannel(), webSocketClientMessage); + onlineUsers.forEach(onlineUser -> { + WebSocketChannelManager.getInstance().sendText(onlineUser.getChannel(), webSocketClientMessage); + }); } }