init
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
package com.ruoyi.cai.notice;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.cai.notice.data.ImVideoAttachR;
|
||||
import com.ruoyi.cai.notice.data.ImVideoR;
|
||||
import com.ruoyi.cai.notice.data.child.ImVideoAttachData;
|
||||
import com.ruoyi.cai.notice.data.child.ImVideoData;
|
||||
import com.ruoyi.yunxin.YunExecutor;
|
||||
import com.ruoyi.yunxin.Yunxin;
|
||||
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 YunxinWsServiceV2 {
|
||||
|
||||
@Autowired
|
||||
private Yunxin yunxin;
|
||||
|
||||
/**
|
||||
* 系统自定义消息通知主播接听电话
|
||||
*/
|
||||
public void sendCallAsync(Long roomId,Long callId,Long receiverId){
|
||||
YunExecutor.YUN_EXECUTOR.execute(() -> {
|
||||
ImVideoAttachData data = new ImVideoAttachData();
|
||||
data.setRoomid(roomId);
|
||||
ImVideoAttachR<ImVideoAttachData> res = ImVideoAttachR.ok(data);
|
||||
YxDataR<YxCommonR> r = yunxin.sendAttachMsg(callId, receiverId, res);
|
||||
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 sendToCallNotify(Long toUid, Long fromUid, CallNoticeEnum status, Long calltime){
|
||||
YunExecutor.YUN_EXECUTOR.execute(() -> {
|
||||
ImVideoData data = new ImVideoData();
|
||||
data.setStatus(status.getCode());
|
||||
data.setFrom_uid(fromUid);
|
||||
data.setTo_uid(toUid);
|
||||
data.setCall_time(calltime);
|
||||
ImVideoR<ImVideoData> res = ImVideoR.ok(data);
|
||||
YxDataR<SendMsgResp> r = yunxin.sendToUserNotice(toUid, fromUid, res);
|
||||
if(r == null || !r.isSuccess()){
|
||||
log.error("云信发送失败【sendCallAsync】r={}", JSON.toJSONString(r));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.ruoyi.cai.notice.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class ImVideoAttachR<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id = 11;
|
||||
|
||||
private T data;
|
||||
|
||||
public static <T> ImVideoAttachR<T> ok(T data) {
|
||||
return restResult(data);
|
||||
}
|
||||
|
||||
|
||||
private static <T> ImVideoAttachR<T> restResult(T data) {
|
||||
ImVideoAttachR<T> r = new ImVideoAttachR<>();
|
||||
r.setData(data);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ruoyi.cai.notice.data;
|
||||
|
||||
import com.ruoyi.cai.notice.enums.MessageBaseTypeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ImVideoR<T> implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer type;
|
||||
|
||||
private T data;
|
||||
|
||||
public static <T> ImVideoR<T> ok(T data) {
|
||||
return restResult(MessageBaseTypeEnum.IM_VIDEO_MESSAGE.getCode(), data);
|
||||
}
|
||||
|
||||
|
||||
private static <T> ImVideoR<T> restResult(Integer type, T data) {
|
||||
ImVideoR<T> r = new ImVideoR<>();
|
||||
r.setType(type);
|
||||
r.setData(data);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.ruoyi.cai.notice.data.child;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ImVideoAttachData {
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ruoyi.cai.notice.data.child;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ImVideoData {
|
||||
private Integer calltype = 1;
|
||||
// 通话状态,1 取消 2 拒绝 3 超时 4 已通话
|
||||
private Integer status;
|
||||
private Long from_uid;
|
||||
private Long to_uid;
|
||||
private Long call_time;
|
||||
}
|
||||
@@ -17,6 +17,7 @@ public enum MessageBaseTypeEnum {
|
||||
@Deprecated
|
||||
REGISTER_SEND_CLEAN(13,"注册发送IM单图文消息"),
|
||||
SEND_GIFT_MESSAGE(14,"发送礼物自定义消息"),
|
||||
IM_VIDEO_MESSAGE(15,"通话通知"),
|
||||
SEND_FOLLOW(16,"自定义被关注消息"),
|
||||
SEND_FOLLOW_DYNAMIC(17,"关注动态"),
|
||||
SEND_ONLINE_ATTENTION(18,"上线了通知"),
|
||||
|
||||
Reference in New Issue
Block a user