|
|
@ -61,7 +61,6 @@ public class WebrtcGroupServiceImpl implements WebrtcGroupService { |
|
|
@Override |
|
|
@Override |
|
|
public void setup(WebrtcGroupSetupDTO dto) { |
|
|
public void setup(WebrtcGroupSetupDTO dto) { |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
log.info("发起群通话,sid:{},群id:{}", userSession.getUserId(), dto.getGroupId()); |
|
|
|
|
|
groupService.getAndCheckById(dto.getGroupId()); |
|
|
groupService.getAndCheckById(dto.getGroupId()); |
|
|
if (dto.getUserInfos().size() > webrtcConfig.getMaxChannel()) { |
|
|
if (dto.getUserInfos().size() > webrtcConfig.getMaxChannel()) { |
|
|
throw new GlobalException("最多支持" + webrtcConfig.getMaxChannel() + "人进行通话"); |
|
|
throw new GlobalException("最多支持" + webrtcConfig.getMaxChannel() + "人进行通话"); |
|
|
@ -127,7 +126,6 @@ public class WebrtcGroupServiceImpl implements WebrtcGroupService { |
|
|
@Override |
|
|
@Override |
|
|
public void accept(Long groupId) { |
|
|
public void accept(Long groupId) { |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
log.info("接受群通话,sid:{},群id:{}", userSession.getUserId(), groupId); |
|
|
|
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(groupId); |
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(groupId); |
|
|
// 校验
|
|
|
// 校验
|
|
|
if (!isExist(webrtcSession, userSession.getUserId())) { |
|
|
if (!isExist(webrtcSession, userSession.getUserId())) { |
|
|
@ -150,7 +148,6 @@ public class WebrtcGroupServiceImpl implements WebrtcGroupService { |
|
|
@Override |
|
|
@Override |
|
|
public void reject(Long groupId) { |
|
|
public void reject(Long groupId) { |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
log.info("拒绝群通话,sid:{},群id:{}", userSession.getUserId(), groupId); |
|
|
|
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(groupId); |
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(groupId); |
|
|
// 校验
|
|
|
// 校验
|
|
|
if (!isExist(webrtcSession, userSession.getUserId())) { |
|
|
if (!isExist(webrtcSession, userSession.getUserId())) { |
|
|
@ -178,7 +175,6 @@ public class WebrtcGroupServiceImpl implements WebrtcGroupService { |
|
|
@Override |
|
|
@Override |
|
|
public void failed(WebrtcGroupFailedDTO dto) { |
|
|
public void failed(WebrtcGroupFailedDTO dto) { |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
log.info("未能进入群通话,sid:{},群id:{},reason:{}", userSession.getUserId(), dto.getGroupId(), dto.getReason()); |
|
|
|
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(dto.getGroupId()); |
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(dto.getGroupId()); |
|
|
// 校验
|
|
|
// 校验
|
|
|
if (!isExist(webrtcSession, userSession.getUserId())) { |
|
|
if (!isExist(webrtcSession, userSession.getUserId())) { |
|
|
@ -209,7 +205,6 @@ public class WebrtcGroupServiceImpl implements WebrtcGroupService { |
|
|
@Override |
|
|
@Override |
|
|
public void join(Long groupId) { |
|
|
public void join(Long groupId) { |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
log.info("加入群通话,sid:{},群id:{},reason:{}", userSession.getUserId(), groupId); |
|
|
|
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(groupId); |
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(groupId); |
|
|
if (webrtcSession.getUserInfos().size() >= webrtcConfig.getMaxChannel()) { |
|
|
if (webrtcSession.getUserInfos().size() >= webrtcConfig.getMaxChannel()) { |
|
|
throw new GlobalException("人员已满,无法进入通话"); |
|
|
throw new GlobalException("人员已满,无法进入通话"); |
|
|
@ -250,7 +245,6 @@ public class WebrtcGroupServiceImpl implements WebrtcGroupService { |
|
|
@Override |
|
|
@Override |
|
|
public void invite(WebrtcGroupInviteDTO dto) { |
|
|
public void invite(WebrtcGroupInviteDTO dto) { |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
log.info("邀请成员加入群通话,sid:{},群id:{}", userSession.getUserId(), dto.getGroupId()); |
|
|
|
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(dto.getGroupId()); |
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(dto.getGroupId()); |
|
|
if (webrtcSession.getUserInfos().size() + dto.getUserInfos().size() > webrtcConfig.getMaxChannel()) { |
|
|
if (webrtcSession.getUserInfos().size() + dto.getUserInfos().size() > webrtcConfig.getMaxChannel()) { |
|
|
throw new GlobalException("最多支持" + webrtcConfig.getMaxChannel() + "人进行通话"); |
|
|
throw new GlobalException("最多支持" + webrtcConfig.getMaxChannel() + "人进行通话"); |
|
|
@ -315,7 +309,6 @@ public class WebrtcGroupServiceImpl implements WebrtcGroupService { |
|
|
@Override |
|
|
@Override |
|
|
public void cancel(Long groupId) { |
|
|
public void cancel(Long groupId) { |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
log.info("取消群通话,sid:{},群id:{}", userSession.getUserId(), groupId); |
|
|
|
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(groupId); |
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(groupId); |
|
|
if (!userSession.getUserId().equals(webrtcSession.getHost().getId())) { |
|
|
if (!userSession.getUserId().equals(webrtcSession.getHost().getId())) { |
|
|
throw new GlobalException("只有发起人可以取消通话"); |
|
|
throw new GlobalException("只有发起人可以取消通话"); |
|
|
@ -330,14 +323,13 @@ public class WebrtcGroupServiceImpl implements WebrtcGroupService { |
|
|
sendRtcMessage1(MessageType.RTC_GROUP_CANCEL, groupId, recvIds, "", false); |
|
|
sendRtcMessage1(MessageType.RTC_GROUP_CANCEL, groupId, recvIds, "", false); |
|
|
// 发送文字提示信息
|
|
|
// 发送文字提示信息
|
|
|
sendTipMessage(groupId, "通话结束"); |
|
|
sendTipMessage(groupId, "通话结束"); |
|
|
log.info("发起人取消群通话,userId:{},groupId:{}", userSession.getUserId(), groupId); |
|
|
log.info("取消群通话,userId:{},groupId:{}", userSession.getUserId(), groupId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@RedisLock(prefixKey = RedisKey.IM_LOCK_RTC_GROUP, key = "#groupId") |
|
|
@RedisLock(prefixKey = RedisKey.IM_LOCK_RTC_GROUP, key = "#groupId") |
|
|
@Override |
|
|
@Override |
|
|
public void quit(Long groupId) { |
|
|
public void quit(Long groupId) { |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
UserSession userSession = SessionContext.getSession(); |
|
|
log.info("退出群通话,sid:{},群id:{}", userSession.getUserId(), groupId); |
|
|
|
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(groupId); |
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(groupId); |
|
|
// 将用户从列表中移除
|
|
|
// 将用户从列表中移除
|
|
|
List<IMUserInfo> inChatUsers = |
|
|
List<IMUserInfo> inChatUsers = |
|
|
@ -380,7 +372,7 @@ public class WebrtcGroupServiceImpl implements WebrtcGroupService { |
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(dto.getGroupId()); |
|
|
WebrtcGroupSession webrtcSession = getWebrtcSession(dto.getGroupId()); |
|
|
IMUserInfo userInfo = findInChatUser(webrtcSession, dto.getUserId()); |
|
|
IMUserInfo userInfo = findInChatUser(webrtcSession, dto.getUserId()); |
|
|
if (Objects.isNull(userInfo)) { |
|
|
if (Objects.isNull(userInfo)) { |
|
|
log.info("对方未加入群通话,userId:{},对方id:{},groupId:{}", userSession.getUserId(), dto.getUserId(), |
|
|
log.warn("对方未加入群通话,userId:{},对方id:{},groupId:{}", userSession.getUserId(), dto.getUserId(), |
|
|
dto.getGroupId()); |
|
|
dto.getGroupId()); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
@ -397,7 +389,7 @@ public class WebrtcGroupServiceImpl implements WebrtcGroupService { |
|
|
IMUserInfo userInfo = findInChatUser(webrtcSession, dto.getUserId()); |
|
|
IMUserInfo userInfo = findInChatUser(webrtcSession, dto.getUserId()); |
|
|
if (Objects.isNull(userInfo)) { |
|
|
if (Objects.isNull(userInfo)) { |
|
|
// 对方未加入群通话
|
|
|
// 对方未加入群通话
|
|
|
log.info("对方未加入群通话,userId:{},对方id:{},groupId:{}", userSession.getUserId(), dto.getUserId(), |
|
|
log.warn("对方未加入群通话,userId:{},对方id:{},groupId:{}", userSession.getUserId(), dto.getUserId(), |
|
|
dto.getGroupId()); |
|
|
dto.getGroupId()); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
@ -414,7 +406,7 @@ public class WebrtcGroupServiceImpl implements WebrtcGroupService { |
|
|
IMUserInfo userInfo = findInChatUser(webrtcSession, dto.getUserId()); |
|
|
IMUserInfo userInfo = findInChatUser(webrtcSession, dto.getUserId()); |
|
|
if (Objects.isNull(userInfo)) { |
|
|
if (Objects.isNull(userInfo)) { |
|
|
// 对方未加入群通话
|
|
|
// 对方未加入群通话
|
|
|
log.info("对方未加入群通话,无法同步candidate,userId:{},remoteUserId:{},groupId:{}", userSession.getUserId(), |
|
|
log.warn("对方未加入群通话,无法同步candidate,userId:{},remoteUserId:{},groupId:{}", userSession.getUserId(), |
|
|
dto.getUserId(), dto.getGroupId()); |
|
|
dto.getUserId(), dto.getGroupId()); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|