新增huawei rtc 呼叫
This commit is contained in:
parent
a3fa8f8eb8
commit
8650856864
@ -0,0 +1,17 @@
|
|||||||
|
package cn.com.tenlion.usercenter.consts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: ISmartCityUserCenterConts
|
||||||
|
* @Description: 常量
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/12/7 11:00 AM
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public interface ISmartCityUserCenterConsts {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP客户端名称
|
||||||
|
*/
|
||||||
|
String APP_CLIENT_NAME = "city-governance";
|
||||||
|
|
||||||
|
}
|
@ -9,7 +9,11 @@ package cn.com.tenlion.usercenter.enums.websocket;
|
|||||||
*/
|
*/
|
||||||
public enum WebSocketCustomTypeEnum {
|
public enum WebSocketCustomTypeEnum {
|
||||||
|
|
||||||
LOCATION_REALTIME(11001, "实时定位");
|
LOCATION_REALTIME(11001, "实时定位"),
|
||||||
|
HUAWEI_RTC_CALL(11002, "华为实时通讯呼叫"),
|
||||||
|
HUAWEI_RTC_CALL_LOGIN_SUCCESS(11201, "华为实时通讯呼叫登录成功"),
|
||||||
|
HUAWEI_RTC_CALL_NOT_SUPPORTED(11401, "华为实时通讯呼叫不支持"),
|
||||||
|
HUAWEI_RTC_CALL_LOGIN_FAILED(11402, "华为实时通讯呼叫登录失败");
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
private String summary;
|
private String summary;
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package cn.com.tenlion.usercenter.service.huaweirtc;
|
||||||
|
|
||||||
|
import ink.wgink.exceptions.websocket.UserOfflineException;
|
||||||
|
import ink.wgink.module.instantmessage.websocket.pojo.WebSocketClientMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: IVideoCallService
|
||||||
|
* @Description: 视频通话
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/12/7 10:46 AM
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public interface IHuaweiRtcService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频呼叫
|
||||||
|
*
|
||||||
|
* @param channel
|
||||||
|
* @param webSocketClientMessage
|
||||||
|
*/
|
||||||
|
void rtcCall(WebSocketClientMessage webSocketClientMessage) throws UserOfflineException;
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package cn.com.tenlion.usercenter.service.huaweirtc.impl;
|
||||||
|
|
||||||
|
import cn.com.tenlion.usercenter.consts.ISmartCityUserCenterConsts;
|
||||||
|
import cn.com.tenlion.usercenter.service.huaweirtc.IHuaweiRtcService;
|
||||||
|
import ink.wgink.exceptions.websocket.UserOfflineException;
|
||||||
|
import ink.wgink.exceptions.websocket.useroffline.RtcUserOfflineException;
|
||||||
|
import ink.wgink.module.instantmessage.websocket.manager.WebSocketChannelManager;
|
||||||
|
import ink.wgink.module.instantmessage.websocket.pojo.WebSocketClientMessage;
|
||||||
|
import ink.wgink.pojo.session.WebSocketSession;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName: VideoCallServiceImpl
|
||||||
|
* @Description: 视频通话
|
||||||
|
* @Author: wanggeng
|
||||||
|
* @Date: 2021/12/7 10:47 AM
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class HuaweiRtcServiceImpl implements IHuaweiRtcService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void rtcCall(WebSocketClientMessage webSocketClientMessage) throws UserOfflineException {
|
||||||
|
String receiverUserId = webSocketClientMessage.getTo();
|
||||||
|
WebSocketSession onlineUser = WebSocketChannelManager.getInstance().getOnlineUser(receiverUserId, ISmartCityUserCenterConsts.APP_CLIENT_NAME);
|
||||||
|
if (onlineUser == null) {
|
||||||
|
throw new RtcUserOfflineException("用户不在线");
|
||||||
|
}
|
||||||
|
WebSocketChannelManager.getInstance().sendText(onlineUser.getChannel(), webSocketClientMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,10 +2,12 @@ package cn.com.tenlion.usercenter.service.websocket;
|
|||||||
|
|
||||||
import cn.com.tenlion.usercenter.enums.websocket.WebSocketCustomTypeEnum;
|
import cn.com.tenlion.usercenter.enums.websocket.WebSocketCustomTypeEnum;
|
||||||
import cn.com.tenlion.usercenter.service.userrealtimelocation.IUserRealtimeLocationService;
|
import cn.com.tenlion.usercenter.service.userrealtimelocation.IUserRealtimeLocationService;
|
||||||
|
import cn.com.tenlion.usercenter.service.huaweirtc.IHuaweiRtcService;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import ink.wgink.common.base.DefaultBaseService;
|
import ink.wgink.common.base.DefaultBaseService;
|
||||||
import ink.wgink.module.instantmessage.service.IWebSocketTextCustomService;
|
import ink.wgink.exceptions.websocket.BaseSocketException;
|
||||||
import ink.wgink.exceptions.websocket.CustomHandleException;
|
import ink.wgink.exceptions.websocket.CustomHandleException;
|
||||||
|
import ink.wgink.module.instantmessage.service.IWebSocketTextCustomService;
|
||||||
import ink.wgink.module.instantmessage.websocket.pojo.WebSocketClientMessage;
|
import ink.wgink.module.instantmessage.websocket.pojo.WebSocketClientMessage;
|
||||||
import ink.wgink.module.map.pojo.vos.userlocation.UserLocationVO;
|
import ink.wgink.module.map.pojo.vos.userlocation.UserLocationVO;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
@ -24,17 +26,26 @@ public class WebSocketTextCustomServiceImpl extends DefaultBaseService implement
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IUserRealtimeLocationService userRealtimeLocationService;
|
private IUserRealtimeLocationService userRealtimeLocationService;
|
||||||
|
@Autowired
|
||||||
|
private IHuaweiRtcService huaweiRtcService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Channel channel, WebSocketClientMessage webSocketClientMessage) throws CustomHandleException {
|
public void handle(Channel fromChannel, WebSocketClientMessage webSocketClientMessage) throws BaseSocketException {
|
||||||
try {
|
try {
|
||||||
if (WebSocketCustomTypeEnum.LOCATION_REALTIME.getValue() == webSocketClientMessage.getType()) {
|
if (WebSocketCustomTypeEnum.LOCATION_REALTIME.getValue() == webSocketClientMessage.getType()) {
|
||||||
UserLocationVO userLocationVO = JSONObject.parseObject(webSocketClientMessage.getBody(), UserLocationVO.class);
|
UserLocationVO userLocationVO = JSONObject.parseObject(webSocketClientMessage.getBody(), UserLocationVO.class);
|
||||||
userRealtimeLocationService.save(userLocationVO);
|
userRealtimeLocationService.save(userLocationVO);
|
||||||
|
} else if (WebSocketCustomTypeEnum.HUAWEI_RTC_CALL.getValue() == webSocketClientMessage.getType()) {
|
||||||
|
huaweiRtcService.rtcCall(webSocketClientMessage);
|
||||||
|
} else if (WebSocketCustomTypeEnum.HUAWEI_RTC_CALL_LOGIN_SUCCESS.getValue() == webSocketClientMessage.getType()) {
|
||||||
|
huaweiRtcService.rtcCall(webSocketClientMessage);
|
||||||
|
} else if (WebSocketCustomTypeEnum.HUAWEI_RTC_CALL_LOGIN_FAILED.getValue() == webSocketClientMessage.getType()) {
|
||||||
|
huaweiRtcService.rtcCall(webSocketClientMessage);
|
||||||
|
} else if (WebSocketCustomTypeEnum.HUAWEI_RTC_CALL_NOT_SUPPORTED.getValue() == webSocketClientMessage.getType()) {
|
||||||
|
huaweiRtcService.rtcCall(webSocketClientMessage);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
throw new CustomHandleException(e.getMessage(), e);
|
||||||
throw new CustomHandleException(e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user