Commit 11952736 by Future

rtc返回去subData扁平化

parent 5b9cb41e
package com.wecloud.im.enums;
import io.geekidea.springbootplus.framework.common.enums.BaseEnum;
/**
* @Author wenzhida
* @Date 2022/2/9 17:25
* @Description 呼叫类型枚举
*/
public enum CallTypeEnum implements BaseEnum {
/**
* 1 - video
*/
VIDEO(1, "video"),
/**
* 2 - voice
*/
VOICE(2, "voice");
CallTypeEnum(int code, String desc) {
this.code = code;
this.desc = desc;
}
private final Integer code;
private final String desc;
@Override
public Integer getCode() {
return this.code;
}
@Override
public String getDesc() {
return this.desc;
}
}
...@@ -97,7 +97,6 @@ public class FriendEventSender { ...@@ -97,7 +97,6 @@ public class FriendEventSender {
PushVO pushVO = new PushVO(); PushVO pushVO = new PushVO();
pushVO.setTitle(FRIEND_APPROVE_TITLE); pushVO.setTitle(FRIEND_APPROVE_TITLE);
pushVO.setSubTitle(isAgree? FRIEND_APPROVE_TITLE_AGREE : FRIEND_APPROVE_TITLE_REJECT); pushVO.setSubTitle(isAgree? FRIEND_APPROVE_TITLE_AGREE : FRIEND_APPROVE_TITLE_REJECT);
// systemPush.push(pushVO, receiveClient, app);
PushDTO pushDTO = mqSender.buildPushDto(pushVO, receiveClient, app); PushDTO pushDTO = mqSender.buildPushDto(pushVO, receiveClient, app);
mqSender.synSend(MqConstant.Topic.IM_MSG_TOPIC, MqConstant.Tag.IM_MSG_TAG, pushDTO); mqSender.synSend(MqConstant.Topic.IM_MSG_TOPIC, MqConstant.Tag.IM_MSG_TAG, pushDTO);
} }
......
...@@ -23,8 +23,8 @@ public class CreateRtcChannelParam implements Serializable { ...@@ -23,8 +23,8 @@ public class CreateRtcChannelParam implements Serializable {
@ApiModelProperty(value = "客户端自定义数据", required = false) @ApiModelProperty(value = "客户端自定义数据", required = false)
private String attrs; private String attrs;
@ApiModelProperty(value = "类型: video或voice", required = true) @ApiModelProperty(value = "类型: 1-video或2-voice", required = true)
private String type; private Integer callType;
@ApiModelProperty(value = "绑定的会话id,可选", required = false) @ApiModelProperty(value = "绑定的会话id,可选", required = false)
private Long conversationId; private Long conversationId;
......
...@@ -7,9 +7,17 @@ import java.io.Serializable; ...@@ -7,9 +7,17 @@ import java.io.Serializable;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class RtcCallResponse extends RtcSubDataBase implements Serializable { public class RtcCallResponse extends RtcDataBase implements Serializable {
private String type; /**
* 类型: "video" 或 "voice"
* @see com.wecloud.im.enums.CallTypeEnum
*/
private Integer callType;
/**
* 会话id
*/
private Long conversationId; private Long conversationId;
} }
...@@ -7,7 +7,7 @@ import java.io.Serializable; ...@@ -7,7 +7,7 @@ import java.io.Serializable;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class RtcCandidateForwardResponse extends RtcSubDataBase implements Serializable { public class RtcCandidateForwardResponse extends RtcDataBase implements Serializable {
/** /**
* 转发的候选者数据 * 转发的候选者数据
......
...@@ -7,6 +7,6 @@ import java.io.Serializable; ...@@ -7,6 +7,6 @@ import java.io.Serializable;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class RtcClientJoinResponse extends RtcSubDataBase implements Serializable { public class RtcClientJoinResponse extends RtcDataBase implements Serializable {
} }
...@@ -7,6 +7,6 @@ import java.io.Serializable; ...@@ -7,6 +7,6 @@ import java.io.Serializable;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class RtcClientLeaveResponse extends RtcSubDataBase implements Serializable { public class RtcClientLeaveResponse extends RtcDataBase implements Serializable {
} }
...@@ -7,6 +7,6 @@ import java.io.Serializable; ...@@ -7,6 +7,6 @@ import java.io.Serializable;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class RtcClientRejectResponse extends RtcSubDataBase implements Serializable { public class RtcClientRejectResponse extends RtcDataBase implements Serializable {
} }
...@@ -5,7 +5,12 @@ import lombok.Data; ...@@ -5,7 +5,12 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@Data @Data
public class RtcSubDataBase implements Serializable { public class RtcDataBase implements Serializable {
/**
* 子指令
*/
private Integer subCmd;
private Long channelId; private Long channelId;
private String clientId; private String clientId;
......
...@@ -7,7 +7,7 @@ import java.io.Serializable; ...@@ -7,7 +7,7 @@ import java.io.Serializable;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class RtcSdpForwardResponse extends RtcSubDataBase implements Serializable { public class RtcSdpForwardResponse extends RtcDataBase implements Serializable {
/** /**
* channelId : 1234263457652 * channelId : 1234263457652
......
...@@ -3,6 +3,8 @@ package com.wecloud.rtc.service.impl; ...@@ -3,6 +3,8 @@ package com.wecloud.rtc.service.impl;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.wecloud.im.entity.ImApplication; import com.wecloud.im.entity.ImApplication;
import com.wecloud.im.entity.ImClient; import com.wecloud.im.entity.ImClient;
import com.wecloud.im.enums.CallTypeEnum;
import com.wecloud.im.enums.FriendStateEnum;
import com.wecloud.im.param.rtc.CandidateForwardParam; import com.wecloud.im.param.rtc.CandidateForwardParam;
import com.wecloud.im.param.rtc.CreateRtcChannelParam; import com.wecloud.im.param.rtc.CreateRtcChannelParam;
import com.wecloud.im.param.rtc.CreateRtcChannelResult; import com.wecloud.im.param.rtc.CreateRtcChannelResult;
...@@ -23,8 +25,10 @@ import com.wecloud.rtc.entity.response.RtcSdpForwardResponse; ...@@ -23,8 +25,10 @@ import com.wecloud.rtc.entity.response.RtcSdpForwardResponse;
import com.wecloud.rtc.service.MangerRtcCacheService; import com.wecloud.rtc.service.MangerRtcCacheService;
import com.wecloud.rtc.service.RtcService; import com.wecloud.rtc.service.RtcService;
import com.wecloud.rtc.service.WsRtcWrite; import com.wecloud.rtc.service.WsRtcWrite;
import io.geekidea.springbootplus.framework.common.api.ApiCode;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
import com.wecloud.utils.SnowflakeUtil; import com.wecloud.utils.SnowflakeUtil;
import io.geekidea.springbootplus.framework.common.enums.BaseEnum;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -79,7 +83,9 @@ public class RtcServiceImpl extends UserStateListener implements RtcService { ...@@ -79,7 +83,9 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
public ApiResult<CreateRtcChannelResult> createAndCall(CreateRtcChannelParam createRtcChannelParam) throws JsonProcessingException { public ApiResult<CreateRtcChannelResult> createAndCall(CreateRtcChannelParam createRtcChannelParam) throws JsonProcessingException {
ImClient client = imClientService.getCurentClient(); ImClient client = imClientService.getCurentClient();
Long rtcChannelId = SnowflakeUtil.getId(); Long rtcChannelId = SnowflakeUtil.getId();
if (BaseEnum.valueOf(CallTypeEnum.class, createRtcChannelParam.getCallType()) == null) {
return ApiResult.fail(ApiCode.PARAMETER_EXCEPTION, null);
}
// 判断发起方必须在线 // 判断发起方必须在线
boolean onlineStatus = userStateCacheManager.isOnline(client.getId()); boolean onlineStatus = userStateCacheManager.isOnline(client.getId());
if (!onlineStatus) { if (!onlineStatus) {
...@@ -95,7 +101,7 @@ public class RtcServiceImpl extends UserStateListener implements RtcService { ...@@ -95,7 +101,7 @@ public class RtcServiceImpl extends UserStateListener implements RtcService {
// ws向接收方发送通知 // ws向接收方发送通知
RtcCallResponse rtcCallResponse = new RtcCallResponse(); RtcCallResponse rtcCallResponse = new RtcCallResponse();
rtcCallResponse.setType(createRtcChannelParam.getType()); rtcCallResponse.setCallType(createRtcChannelParam.getCallType());
// rtcCallResponse.setConversationId(createRtcChannelParam.getConversationId()); // rtcCallResponse.setConversationId(createRtcChannelParam.getConversationId());
rtcCallResponse.setChannelId(rtcChannelId); rtcCallResponse.setChannelId(rtcChannelId);
rtcCallResponse.setClientId(client.getClientId()); rtcCallResponse.setClientId(client.getClientId());
......
...@@ -9,7 +9,6 @@ import com.wecloud.rtc.entity.response.RtcCandidateForwardResponse; ...@@ -9,7 +9,6 @@ import com.wecloud.rtc.entity.response.RtcCandidateForwardResponse;
import com.wecloud.rtc.entity.response.RtcClientJoinResponse; import com.wecloud.rtc.entity.response.RtcClientJoinResponse;
import com.wecloud.rtc.entity.response.RtcClientLeaveResponse; import com.wecloud.rtc.entity.response.RtcClientLeaveResponse;
import com.wecloud.rtc.entity.response.RtcClientRejectResponse; import com.wecloud.rtc.entity.response.RtcClientRejectResponse;
import com.wecloud.rtc.entity.response.RtcResponseBase;
import com.wecloud.rtc.entity.response.RtcSdpForwardResponse; import com.wecloud.rtc.entity.response.RtcSdpForwardResponse;
import com.wecloud.rtc.service.WsRtcWrite; import com.wecloud.rtc.service.WsRtcWrite;
import io.geekidea.springbootplus.framework.common.api.ApiCode; import io.geekidea.springbootplus.framework.common.api.ApiCode;
...@@ -25,19 +24,15 @@ public class WsRtcWriteImpl implements WsRtcWrite { ...@@ -25,19 +24,15 @@ public class WsRtcWriteImpl implements WsRtcWrite {
@Override @Override
public void rtcCall(RtcCallResponse rtcCallResponse, Long toClientId) { public void rtcCall(RtcCallResponse rtcCallResponse, Long toClientId) {
rtcCallResponse.setSubCmd(WsRtcResponseSubCmdEnum.RTC_CALL.getCmdCode());
RtcResponseBase<RtcCallResponse> rtcResponseBase = new RtcResponseBase<>();
rtcResponseBase.setSubCmd(WsRtcResponseSubCmdEnum.RTC_CALL.getCmdCode());
rtcResponseBase.setSubData(rtcCallResponse);
// rtcResponseBase.setAttrs(rtcCallResponse.get);
// 向接收方推送 // 向接收方推送
WsResponse<RtcResponseBase<RtcCallResponse>> responseModel = new WsResponse<>(); WsResponse<RtcCallResponse> responseModel = new WsResponse<>();
responseModel.setCmd(WsResponseCmdEnum.SINGLE_RTC_MSG.getCmdCode()); responseModel.setCmd(WsResponseCmdEnum.SINGLE_RTC_MSG.getCmdCode());
ApiResult<Boolean> result = ApiResult.result(ApiCode.SUCCESS); ApiResult<Boolean> result = ApiResult.result(ApiCode.SUCCESS);
responseModel.setCode(result.getCode()); responseModel.setCode(result.getCode());
responseModel.setMsg(result.getMessage()); responseModel.setMsg(result.getMessage());
responseModel.setData(rtcResponseBase); responseModel.setData(rtcCallResponse);
responseModel.setReqId(null); responseModel.setReqId(null);
channelSender.sendMsg(responseModel, toClientId); channelSender.sendMsg(responseModel, toClientId);
...@@ -45,19 +40,15 @@ public class WsRtcWriteImpl implements WsRtcWrite { ...@@ -45,19 +40,15 @@ public class WsRtcWriteImpl implements WsRtcWrite {
@Override @Override
public void clientJoin(RtcClientJoinResponse rtcClientJoinResponse, Long toClientId) { public void clientJoin(RtcClientJoinResponse rtcClientJoinResponse, Long toClientId) {
rtcClientJoinResponse.setSubCmd(WsRtcResponseSubCmdEnum.CLIENT_JOIN.getCmdCode());
RtcResponseBase<RtcClientJoinResponse> rtcResponseBase = new RtcResponseBase<>();
rtcResponseBase.setSubCmd(WsRtcResponseSubCmdEnum.CLIENT_JOIN.getCmdCode());
rtcResponseBase.setSubData(rtcClientJoinResponse);
// rtcResponseBase.setAttrs(rtcCallResponse.get);
// 向接收方推送 // 向接收方推送
WsResponse<RtcResponseBase<RtcClientJoinResponse>> responseModel = new WsResponse<>(); WsResponse<RtcClientJoinResponse> responseModel = new WsResponse<>();
responseModel.setCmd(WsResponseCmdEnum.SINGLE_RTC_MSG.getCmdCode()); responseModel.setCmd(WsResponseCmdEnum.SINGLE_RTC_MSG.getCmdCode());
ApiResult<Boolean> result = ApiResult.result(ApiCode.SUCCESS); ApiResult<Boolean> result = ApiResult.result(ApiCode.SUCCESS);
responseModel.setCode(result.getCode()); responseModel.setCode(result.getCode());
responseModel.setMsg(result.getMessage()); responseModel.setMsg(result.getMessage());
responseModel.setData(rtcResponseBase); responseModel.setData(rtcClientJoinResponse);
responseModel.setReqId(null); responseModel.setReqId(null);
channelSender.sendMsg(responseModel, toClientId); channelSender.sendMsg(responseModel, toClientId);
...@@ -66,20 +57,15 @@ public class WsRtcWriteImpl implements WsRtcWrite { ...@@ -66,20 +57,15 @@ public class WsRtcWriteImpl implements WsRtcWrite {
@Override @Override
public void clientLeave(RtcClientLeaveResponse rtcClientLeaveResponse, Long toClientId) { public void clientLeave(RtcClientLeaveResponse rtcClientLeaveResponse, Long toClientId) {
rtcClientLeaveResponse.setSubCmd(WsRtcResponseSubCmdEnum.CLIENT_LEAVE.getCmdCode());
RtcResponseBase<RtcClientLeaveResponse> rtcResponseBase = new RtcResponseBase<>();
rtcResponseBase.setSubCmd(WsRtcResponseSubCmdEnum.CLIENT_LEAVE.getCmdCode());
rtcResponseBase.setSubData(rtcClientLeaveResponse);
// rtcResponseBase.setAttrs(rtcCallResponse.get);
// 向接收方推送 // 向接收方推送
WsResponse<RtcResponseBase<RtcClientLeaveResponse>> responseModel = new WsResponse<>(); WsResponse<RtcClientLeaveResponse> responseModel = new WsResponse<>();
responseModel.setCmd(WsResponseCmdEnum.SINGLE_RTC_MSG.getCmdCode()); responseModel.setCmd(WsResponseCmdEnum.SINGLE_RTC_MSG.getCmdCode());
ApiResult<Boolean> result = ApiResult.result(ApiCode.SUCCESS); ApiResult<Boolean> result = ApiResult.result(ApiCode.SUCCESS);
responseModel.setCode(result.getCode()); responseModel.setCode(result.getCode());
responseModel.setMsg(result.getMessage()); responseModel.setMsg(result.getMessage());
responseModel.setData(rtcResponseBase); responseModel.setData(rtcClientLeaveResponse);
responseModel.setReqId(null); responseModel.setReqId(null);
channelSender.sendMsg(responseModel, toClientId); channelSender.sendMsg(responseModel, toClientId);
...@@ -87,60 +73,47 @@ public class WsRtcWriteImpl implements WsRtcWrite { ...@@ -87,60 +73,47 @@ public class WsRtcWriteImpl implements WsRtcWrite {
@Override @Override
public void clientReject(RtcClientRejectResponse rtcClientRejectResponse, Long toClientId) { public void clientReject(RtcClientRejectResponse rtcClientRejectResponse, Long toClientId) {
rtcClientRejectResponse.setSubCmd(WsRtcResponseSubCmdEnum.CLIENT_REJECT.getCmdCode());
RtcResponseBase<RtcClientRejectResponse> rtcResponseBase = new RtcResponseBase<>();
rtcResponseBase.setSubCmd(WsRtcResponseSubCmdEnum.CLIENT_REJECT.getCmdCode());
rtcResponseBase.setSubData(rtcClientRejectResponse);
// rtcResponseBase.setAttrs(rtcCallResponse.get);
// 向接收方推送 // 向接收方推送
WsResponse<RtcResponseBase<RtcClientRejectResponse>> responseModel = new WsResponse<>(); WsResponse<RtcClientRejectResponse> responseModel = new WsResponse<>();
responseModel.setCmd(WsResponseCmdEnum.SINGLE_RTC_MSG.getCmdCode()); responseModel.setCmd(WsResponseCmdEnum.SINGLE_RTC_MSG.getCmdCode());
ApiResult<Boolean> result = ApiResult.result(ApiCode.SUCCESS); ApiResult<Boolean> result = ApiResult.result(ApiCode.SUCCESS);
responseModel.setCode(result.getCode()); responseModel.setCode(result.getCode());
responseModel.setMsg(result.getMessage()); responseModel.setMsg(result.getMessage());
responseModel.setData(rtcResponseBase); responseModel.setData(rtcClientRejectResponse);
responseModel.setReqId(null); responseModel.setReqId(null);
channelSender.sendMsg(responseModel, toClientId); channelSender.sendMsg(responseModel, toClientId);
} }
@Override @Override
public void sdpForward(RtcSdpForwardResponse rtcSdpForwardResponse, Long toClientId) { public void sdpForward(RtcSdpForwardResponse rtcSdpForwardResponse, Long toClientId) {
rtcSdpForwardResponse.setSubCmd(WsRtcResponseSubCmdEnum.SDP_FORWARD.getCmdCode());
RtcResponseBase<RtcSdpForwardResponse> rtcResponseBase = new RtcResponseBase<>();
rtcResponseBase.setSubCmd(WsRtcResponseSubCmdEnum.SDP_FORWARD.getCmdCode());
rtcResponseBase.setSubData(rtcSdpForwardResponse);
// rtcResponseBase.setAttrs(rtcCallResponse.get);
// 向接收方推送 // 向接收方推送
WsResponse<RtcResponseBase<RtcSdpForwardResponse>> responseModel = new WsResponse<>(); WsResponse<RtcSdpForwardResponse> responseModel = new WsResponse<>();
responseModel.setCmd(WsResponseCmdEnum.SINGLE_RTC_MSG.getCmdCode()); responseModel.setCmd(WsResponseCmdEnum.SINGLE_RTC_MSG.getCmdCode());
ApiResult<Boolean> result = ApiResult.result(ApiCode.SUCCESS); ApiResult<Boolean> result = ApiResult.result(ApiCode.SUCCESS);
responseModel.setCode(result.getCode()); responseModel.setCode(result.getCode());
responseModel.setMsg(result.getMessage()); responseModel.setMsg(result.getMessage());
responseModel.setData(rtcResponseBase); responseModel.setData(rtcSdpForwardResponse);
responseModel.setReqId(null); responseModel.setReqId(null);
channelSender.sendMsg(responseModel, toClientId); channelSender.sendMsg(responseModel, toClientId);
} }
@Override @Override
public void candidateForward(RtcCandidateForwardResponse rtcCandidateForwardResponse, Long toClientId) { public void candidateForward(RtcCandidateForwardResponse rtcCandidateForwardResponse, Long toClientId) {
rtcCandidateForwardResponse.setSubCmd(WsRtcResponseSubCmdEnum.CANDIDATE_FORWARD.getCmdCode());
RtcResponseBase<RtcCandidateForwardResponse> rtcResponseBase = new RtcResponseBase<>();
rtcResponseBase.setSubCmd(WsRtcResponseSubCmdEnum.CANDIDATE_FORWARD.getCmdCode());
rtcResponseBase.setSubData(rtcCandidateForwardResponse);
// rtcResponseBase.setAttrs(rtcCallResponse.get);
// 向接收方推送 // 向接收方推送
WsResponse<RtcResponseBase<RtcCandidateForwardResponse>> responseModel = new WsResponse<>(); WsResponse<RtcCandidateForwardResponse> responseModel = new WsResponse<>();
responseModel.setCmd(WsResponseCmdEnum.SINGLE_RTC_MSG.getCmdCode()); responseModel.setCmd(WsResponseCmdEnum.SINGLE_RTC_MSG.getCmdCode());
ApiResult<Boolean> result = ApiResult.result(ApiCode.SUCCESS); ApiResult<Boolean> result = ApiResult.result(ApiCode.SUCCESS);
responseModel.setCode(result.getCode()); responseModel.setCode(result.getCode());
responseModel.setMsg(result.getMessage()); responseModel.setMsg(result.getMessage());
responseModel.setData(rtcResponseBase); responseModel.setData(rtcCandidateForwardResponse);
responseModel.setReqId(null); responseModel.setReqId(null);
channelSender.sendMsg(responseModel, toClientId); channelSender.sendMsg(responseModel, toClientId);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment