This commit is contained in:
dute7liang
2024-01-25 22:26:25 +08:00
parent b0ff90a0a0
commit 7dbc4022b7
8 changed files with 55 additions and 13 deletions

View File

@@ -15,6 +15,7 @@ import com.ruoyi.cai.ws.handler.IMessageHandler;
import com.ruoyi.cai.ws.service.RoomService;
import com.ruoyi.cai.ws.dto.WsRMsgGen;
import com.ruoyi.cai.ws.handler.AbstractMessageHandle;
import com.ruoyi.yunxin.enums.CallNoticeEnum;
import com.ruoyi.yunxin.service.YunxinWsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -50,7 +51,7 @@ public class CancelMessageHandler extends AbstractMessageHandle implements IMess
// IM
Long receiverId = room.getReceiverId();
Long callerId = room.getCallId();
yunxinWsService.sendToCallNotifyAsync(callerId,receiverId,1,0L);
yunxinWsService.sendToCallNotifyAsync(receiverId,callerId, CallNoticeEnum.CLOSE,0L);
// 更新房间状态
userCallService.update(Wrappers.lambdaUpdate(UserCall.class)
.eq(UserCall::getId,roomId)

View File

@@ -15,6 +15,7 @@ import com.ruoyi.cai.ws.handler.IMessageHandler;
import com.ruoyi.cai.ws.service.RoomService;
import com.ruoyi.cai.ws.dto.WsRMsgGen;
import com.ruoyi.cai.ws.handler.AbstractMessageHandle;
import com.ruoyi.yunxin.enums.CallNoticeEnum;
import com.ruoyi.yunxin.service.YunxinWsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -29,7 +30,8 @@ public class RefuseMessageHandler extends AbstractMessageHandle implements IMess
@Autowired
private UserCallService userCallService;
@Autowired
private Yunxin yunxin;
private YunxinWsService yunxinWsService;
@Override
public void processOn(Room room, FdCtxData fdCtxData, JSONObject map) {
if(!fdCtxData.isReceiver() || !RoomStatusEnums.STATUS_RECEIVER_CONNECT.getCode().equals(room.getStatus())){
@@ -46,7 +48,7 @@ public class RefuseMessageHandler extends AbstractMessageHandle implements IMess
//发送IM通知
Long receiverId = room.getReceiverId();
Long callerId = room.getCallId();
yunxinWsService.sendToCallNotifyAsync(callerId,receiverId,1,0L);
yunxinWsService.sendToCallNotifyAsync(callerId,receiverId, CallNoticeEnum.REFUSE,0L);
// 更新房间状态
userCallService.update(Wrappers.lambdaUpdate(UserCall.class)
@@ -54,6 +56,5 @@ public class RefuseMessageHandler extends AbstractMessageHandle implements IMess
.set(UserCall::getStatus,RoomStatusEnums.STATUS_REFUSE.getCode()));
}
@Autowired
private YunxinWsService yunxinWsService;
}

View File

@@ -18,6 +18,7 @@ import com.ruoyi.cai.ws.service.SettleResp;
import com.ruoyi.cai.ws.service.SettleService;
import com.ruoyi.cai.ws.util.RoomWebSocketUtil;
import com.ruoyi.yunxin.Yunxin;
import com.ruoyi.yunxin.enums.CallNoticeEnum;
import com.ruoyi.yunxin.service.YunxinWsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -129,7 +130,7 @@ public class RoomCheckJobService {
nextCreateJob = settleResp.isNextRun();
}
roomService.closeAllFd(roomId);
yunxinWsService.sendToCallNotifyAsync(callUserData.getId(),receiverUserData.getId(),3,0L);
yunxinWsService.sendToCallNotifyAsync(callUserData.getId(),receiverUserData.getId(), CallNoticeEnum.TIMEOUT,0L);
return JobResp.builder().nextCreateJob(nextCreateJob).build();
}
return JobResp.builder().nextCreateJob(true).build();

View File

@@ -18,6 +18,7 @@ import com.ruoyi.cai.ws.dto.WsR;
import com.ruoyi.cai.ws.dto.WsRMsgGen;
import com.ruoyi.cai.ws.util.RoomWebSocketUtil;
import com.ruoyi.yunxin.Yunxin;
import com.ruoyi.yunxin.enums.CallNoticeEnum;
import com.ruoyi.yunxin.service.YunxinWsService;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
@@ -156,12 +157,12 @@ public class SettleService {
Long callId = room.getCallUserData().getId();
Long receiveId = room.getReceiverUserData().getId();
if(callTime > 0){
yunxinWsService.sendToCallNotifyAsync(callId,receiveId,4,callTime);
yunxinWsService.sendToCallNotifyAsync(callId,receiveId, CallNoticeEnum.CALL_ALREADY,callTime);
}
// 接收方通知
Long anchorIncome = resp.getAnchorIncome();
if(anchorIncome > 0){
yunxinWsService.sendToCallNotifyAsync(receiveId,callId,4,callTime);
yunxinWsService.sendToCallNotifyAsync(receiveId,callId,CallNoticeEnum.CALL_ALREADY,callTime);
// 收入通知
// ImMsgGen.videoIncome();
// yunxin.sendTo(receiveId,null,)