init
This commit is contained in:
@@ -27,6 +27,13 @@ public class Yunxin {
|
||||
@Resource
|
||||
private ImMessageClient messageClient;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param toUid 接收者ID
|
||||
* @param fromUid 发送者ID
|
||||
* @param data 数据
|
||||
* @return
|
||||
*/
|
||||
public YxDataR<SendMsgResp> sendTo(Long toUid,Long fromUid,Object data){
|
||||
SendMsgReq req = new SendMsgReq();
|
||||
req.setFrom(fromUid == null ? yunxinProperties.getDefaultFromUid() : fromUid+"");
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.ruoyi.yunxin.data;
|
||||
|
||||
import com.ruoyi.yunxin.enums.CallNoticeEnum;
|
||||
|
||||
public class ImMsgGen {
|
||||
|
||||
/**
|
||||
@@ -9,12 +11,12 @@ public class ImMsgGen {
|
||||
* @param to
|
||||
* @param callTime
|
||||
*/
|
||||
public static ImDataRes callNotice(int status,Long from,Long to,long 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); // 通话状态,1 取消 2 拒绝 3 超时 4 已通话
|
||||
imData.setStatus(status.getCode()); // 通话状态,1 取消 2 拒绝 3 超时 4 已通话
|
||||
imData.setFrom_uid(from);
|
||||
imData.setTo_uid(to);
|
||||
imData.setCall_time(callTime);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ruoyi.yunxin.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
// // 通话状态,1 取消 2 拒绝 3 超时 4 已通话
|
||||
@Getter
|
||||
public enum CallNoticeEnum {
|
||||
CLOSE(1,"取消"),
|
||||
REFUSE(2,"拒绝"),
|
||||
TIMEOUT(3,"超时"),
|
||||
CALL_ALREADY(4,"已通话"),
|
||||
|
||||
;
|
||||
private final Integer code;
|
||||
private final String name;
|
||||
|
||||
CallNoticeEnum(Integer code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ 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;
|
||||
@@ -32,10 +33,17 @@ public class YunxinWsService {
|
||||
});
|
||||
}
|
||||
|
||||
public void sendToCallNotifyAsync(Long from,Long to,Integer status,Long calltime){
|
||||
/**
|
||||
* 发送消息
|
||||
* @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, from, to, calltime);
|
||||
YxDataR<SendMsgResp> r = yunxin.sendTo(from, to, imDataRes);
|
||||
ImDataRes imDataRes = ImMsgGen.callNotice(status, fromUid, toUid, calltime);
|
||||
YxDataR<SendMsgResp> r = yunxin.sendTo(toUid, fromUid, imDataRes);
|
||||
if(r == null || !r.isSuccess()){
|
||||
log.error("云信发送失败【sendCallAsync】r={}", JSON.toJSONString(r));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user