|
@@ -56,6 +56,7 @@ public class WebSocketMobileServer {
|
|
|
private RedisUtil redisUtil;
|
|
|
private Long updateTime = null;
|
|
|
private Map<String, Object> tranMap = null;
|
|
|
+ private MonitorVideoSourceEnum source = null;
|
|
|
|
|
|
/**
|
|
|
* 连接建立成功调用的方法
|
|
@@ -79,6 +80,7 @@ public class WebSocketMobileServer {
|
|
|
this.Authorization = String.valueOf(mapParameter.get("Authorization").get(0));
|
|
|
this.time = Long.parseLong(String.valueOf(mapParameter.get("time").get(0)));
|
|
|
this.recordId = Long.parseLong(String.valueOf(mapParameter.get("recordId").get(0)));
|
|
|
+ this.source = MonitorVideoSourceEnum.valueOf(mapParameter.get("source").get(0));
|
|
|
String method = SystemConstant.GET;
|
|
|
final SignatureInfo info = SignatureInfo
|
|
|
.parse(Authorization);
|
|
@@ -135,28 +137,18 @@ public class WebSocketMobileServer {
|
|
|
//从set中删除
|
|
|
subOnlineCount();
|
|
|
//判断是否是正常退出
|
|
|
-// Date now = new Date();
|
|
|
-// //大于等于超时时间,说明规定时间内都没有通信,非正常退出,因为期间会有心跳更新updateTime
|
|
|
-// if ((now.getTime() - this.updateTime) / 1000 >= SystemConstant.WEBSOCKET_MAX_TIME_OUT / 1000) {
|
|
|
Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(recordId));
|
|
|
- MonitorVideoSourceEnum source = null;
|
|
|
- if (Objects.nonNull(objectMap.get(SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.MOBILE_FIRST.name()))) {
|
|
|
- source = MonitorVideoSourceEnum.MOBILE_FIRST;
|
|
|
- } else if (Objects.nonNull(objectMap.get(SystemConstant.MONITOR_LIVE_URL_ + MonitorVideoSourceEnum.MOBILE_SECOND.name()))) {
|
|
|
- source = MonitorVideoSourceEnum.MOBILE_SECOND;
|
|
|
- }
|
|
|
- objectMap.put(SystemConstant.MONITOR_STATUS_ + source.name(), MonitorStatusSourceEnum.STOP);
|
|
|
+ objectMap.put(SystemConstant.MONITOR_STATUS_ + this.source.name(), MonitorStatusSourceEnum.STOP);
|
|
|
redisUtil.setForHash(RedisKeyHelper.examRecordCacheKey(recordId), objectMap);
|
|
|
ConcurrentHashMap<Long, WebSocketOeServer> webSocketMap = WebSocketOeServer.getWebSocketMap();
|
|
|
if (Objects.nonNull(webSocketMap.get(recordId))) {
|
|
|
WebSocketOeServer webSocketOeServer = webSocketMap.get(recordId);
|
|
|
Map map = new HashMap<>();
|
|
|
map.put(SystemConstant.RECORD_ID, recordId);
|
|
|
- map.put("monitorVideoSource", source.name());
|
|
|
+ map.put("monitorVideoSource", this.source.name());
|
|
|
WebsocketDto websocketDto = new WebsocketDto(WebsocketTypeEnum.MOBILE_MONITOR_STOP.name(), map);
|
|
|
webSocketOeServer.sendMessage(websocketDto);
|
|
|
}
|
|
|
-// }
|
|
|
}
|
|
|
log.info("用户退出:{},当前在线人数为:{},updateTime:{}", this.sessionId, getOnlineCount(), this.updateTime);
|
|
|
}
|
|
@@ -180,7 +172,6 @@ public class WebSocketMobileServer {
|
|
|
WebSocketMobileMessageTemplete webSocketMobileMessageTemplete = SpringContextHolder.getBean(WebSocketMobileMessageTemplete.class);
|
|
|
Gson gson = new Gson();
|
|
|
WebsocketDto websocketDto = gson.fromJson(gson.toJson(jsonObject), WebsocketDto.class);
|
|
|
- //todo 加入当前时间和time比较的校验
|
|
|
jsonObject.getJSONObject("body").put("recordId", this.recordId);
|
|
|
websocketDto.setBody(jsonObject.getJSONObject("body"));
|
|
|
Method method = webSocketMobileMessageTemplete.getClass().getDeclaredMethod(WebsocketTypeEnum.valueOf(websocketDto.getType()).getDesc(), String.class);
|