init
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
package com.ruoyi.yunxin.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ImDataRes {
|
||||
private Integer type;
|
||||
private ImData data;
|
||||
|
||||
@Data
|
||||
public static class ImData {
|
||||
private Integer calltype;
|
||||
// 通话状态,1 取消 2 拒绝 3 超时 4 已通话
|
||||
private Integer status;
|
||||
private Long from_uid;
|
||||
private Long to_uid;
|
||||
private Long call_time;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.ruoyi.yunxin.data;
|
||||
|
||||
import com.ruoyi.yunxin.enums.CallNoticeEnum;
|
||||
|
||||
public class ImMsgGen {
|
||||
|
||||
/**
|
||||
* 通话通知
|
||||
* @param status
|
||||
* @param from
|
||||
* @param to
|
||||
* @param callTime
|
||||
*/
|
||||
public static ImDataRes callNotice(CallNoticeEnum status, Long from, Long to, long callTime){
|
||||
ImDataRes imDataRes = new ImDataRes();
|
||||
imDataRes.setType(15);
|
||||
ImDataRes.ImData imData = new ImDataRes.ImData();
|
||||
imData.setCalltype(1);
|
||||
imData.setStatus(status.getCode()); // 通话状态,1 取消 2 拒绝 3 超时 4 已通话
|
||||
imData.setFrom_uid(from);
|
||||
imData.setTo_uid(to);
|
||||
imData.setCall_time(callTime);
|
||||
imDataRes.setData(imData);
|
||||
return imDataRes;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.ruoyi.yunxin.data;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* ws专用
|
||||
*/
|
||||
@Data
|
||||
public class WsSendAttachMsgData {
|
||||
private Integer id = 11;
|
||||
private SendAttachMsgDataMsg data;
|
||||
|
||||
@Data
|
||||
public static class SendAttachMsgDataMsg {
|
||||
private Integer amount = 0;
|
||||
private Long callTime = DateUtil.currentSeconds();
|
||||
private Long gifttotal = 0L;
|
||||
private Integer id = 0;
|
||||
private Integer link_type = 0;
|
||||
private Long time = 0L;
|
||||
private Long toid = 0L;
|
||||
private Long roomid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.ruoyi.yunxin.service;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.yunxin.YunExecutor;
|
||||
import com.ruoyi.yunxin.Yunxin;
|
||||
import com.ruoyi.yunxin.data.ImDataRes;
|
||||
import com.ruoyi.yunxin.data.ImMsgGen;
|
||||
import com.ruoyi.yunxin.data.WsSendAttachMsgData;
|
||||
import com.ruoyi.yunxin.enums.CallNoticeEnum;
|
||||
import com.ruoyi.yunxin.resp.SendMsgResp;
|
||||
import com.ruoyi.yunxin.resp.YxCommonR;
|
||||
import com.ruoyi.yunxin.resp.YxDataR;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class YunxinWsService {
|
||||
|
||||
@Autowired
|
||||
private Yunxin yunxin;
|
||||
public void sendCallAsync(Long roomId,Long callId,Long receiverId){
|
||||
YunExecutor.YUN_EXECUTOR.execute(() -> {
|
||||
WsSendAttachMsgData data = new WsSendAttachMsgData();
|
||||
WsSendAttachMsgData.SendAttachMsgDataMsg msgDataMsg = new WsSendAttachMsgData.SendAttachMsgDataMsg();
|
||||
msgDataMsg.setRoomid(roomId);
|
||||
data.setData(msgDataMsg);
|
||||
YxDataR<YxCommonR> r = yunxin.sendAttachMsg(callId, receiverId, data);
|
||||
if(r == null || !r.isSuccess()){
|
||||
log.error("云信发送失败【sendCallAsync】r={}", JSON.toJSONString(r));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
* @param toUid 接收着ID
|
||||
* @param fromUid 发送着ID
|
||||
* @param status 状态 // 通话状态,1 取消 2 拒绝 3 超时 4 已通话
|
||||
* @param calltime 通话时长
|
||||
*/
|
||||
public void sendToCallNotifyAsync(Long toUid, Long fromUid, CallNoticeEnum status, Long calltime){
|
||||
YunExecutor.YUN_EXECUTOR.execute(() -> {
|
||||
ImDataRes imDataRes = ImMsgGen.callNotice(status, fromUid, toUid, calltime);
|
||||
YxDataR<SendMsgResp> r = yunxin.sendToUserNotice(toUid, fromUid, imDataRes);
|
||||
if(r == null || !r.isSuccess()){
|
||||
log.error("云信发送失败【sendCallAsync】r={}", JSON.toJSONString(r));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user