通话逻辑
This commit is contained in:
@@ -14,6 +14,7 @@ import com.ruoyi.cai.service.CaiAnchorService;
|
||||
import com.ruoyi.cai.service.CaiGuardTotalService;
|
||||
import com.ruoyi.cai.service.CaiUserCallService;
|
||||
import com.ruoyi.cai.service.CaiUserService;
|
||||
import com.ruoyi.cai.ws.bean.Room;
|
||||
import com.ruoyi.cai.ws.manager.WebSocketManager;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
@@ -58,10 +59,11 @@ public class ChatManager {
|
||||
if(anchor == null){
|
||||
throw new ServiceException("主播技能不存在");
|
||||
}
|
||||
String roomId = webSocketManager.checkOnlineRoom(fromUser.getId(), toUser.getId());
|
||||
if(StringUtils.isEmpty(roomId)){
|
||||
String roomId = null;
|
||||
Room room = webSocketManager.checkOnlineRoom(fromUser.getId(), toUser.getId());
|
||||
if(room == null){
|
||||
CaiUserCall call = userCallService.createCall(fromUser, toUser, anchor);
|
||||
roomId = webSocketManager.createRoom(call.getId());
|
||||
roomId = webSocketManager.createRoom(call.getId()+"");
|
||||
}
|
||||
String weSocketUrl = String.format(properties.getWebSocketUrl(),"token",roomId);
|
||||
Long guardPrice = systemConfigManager.getSystemConfigOfLong(SystemConfigEnum.GUARD_PRICE);
|
||||
@@ -96,11 +98,10 @@ public class ChatManager {
|
||||
if(!userCall.getFromUid().equals(userId) && !userCall.getToUid().equals(userId)){
|
||||
throw new ServiceException("无权限操作房间");
|
||||
}
|
||||
String roomIdNew = webSocketManager.checkOnlineRoom(userCall.getFromUid(), userCall.getToUid());
|
||||
if (StringUtils.isNotEmpty(roomIdNew)) {
|
||||
throw new ServiceException("'服务繁忙'");
|
||||
Room room = webSocketManager.checkOnlineRoom(userCall.getFromUid(), userCall.getToUid());
|
||||
if (room == null) {
|
||||
throw new ServiceException("'对方已取消通话'");
|
||||
}
|
||||
// 判断房间号是否还存在 TODO
|
||||
List<CaiUser> userList = userService.listByIds(Arrays.asList(userCall.getFromUid(), userCall.getToUid()));
|
||||
Map<Long, CaiUser> userMap = userList.stream().collect(Collectors.toMap(CaiUser::getId, Function.identity()));
|
||||
CaiUser fromUser = userMap.get(userCall.getFromUid());
|
||||
|
||||
Reference in New Issue
Block a user