|
@@ -162,40 +162,27 @@ public class WebSocketOeServer implements Concurrently {
|
|
|
log.warn("Authorization faile: deviceId invalid, session deviceId is " + tbSession.getDeviceId());
|
|
|
throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
|
|
|
}
|
|
|
- this.session = session;
|
|
|
- session.setMaxIdleTimeout(SystemConstant.WEBSOCKET_MAX_TIME_OUT);
|
|
|
- this.sessionId = tbSession.getId();
|
|
|
- if (webSocketMap.containsKey(this.recordId)) {
|
|
|
- webSocketMap.remove(this.recordId);
|
|
|
- webSocketMap.put(this.recordId, this);
|
|
|
- } else {
|
|
|
- webSocketMap.put(this.recordId, this);
|
|
|
- addOnlineCount();
|
|
|
+ Boolean check = WebsocketUtil.checkExamStatus(this.recordId);
|
|
|
+ if (check) {
|
|
|
+ this.session = session;
|
|
|
+ session.setMaxIdleTimeout(SystemConstant.WEBSOCKET_MAX_TIME_OUT);
|
|
|
+ this.sessionId = tbSession.getId();
|
|
|
+ if (webSocketMap.containsKey(this.recordId)) {
|
|
|
+ webSocketMap.remove(this.recordId);
|
|
|
+ webSocketMap.put(this.recordId, this);
|
|
|
+ } else {
|
|
|
+ webSocketMap.put(this.recordId, this);
|
|
|
+ addOnlineCount();
|
|
|
+ }
|
|
|
+ log.info("用户连接:{},当前在线人数为:{}", this.sessionId, getOnlineCount());
|
|
|
+ InetSocketAddress addr = (InetSocketAddress) WebsocketUtil
|
|
|
+ .getFieldInstance(this.session.getAsyncRemote(), "base#socketWrapper#socket#sc#remoteAddress");
|
|
|
+ this.ip = addr.toString().replace("/", "").split(":")[0];
|
|
|
+ log.info("ip[:{}]连接成功", this.ip);
|
|
|
+ WebsocketUtil.updateExamRecordWebsocketStatus(recordId, ip, this.session.getId(), WebsocketStatusEnum.ON_LINE);
|
|
|
+ this.updateTime = System.currentTimeMillis();
|
|
|
+ tranMap = WebsocketUtil.initWebsocket(recordId, null, deviceId, ip, updateTime);
|
|
|
}
|
|
|
- log.info("用户连接:{},当前在线人数为:{}", this.sessionId, getOnlineCount());
|
|
|
- InetSocketAddress addr = (InetSocketAddress) WebsocketUtil
|
|
|
- .getFieldInstance(this.session.getAsyncRemote(), "base#socketWrapper#socket#sc#remoteAddress");
|
|
|
- this.ip = addr.toString().replace("/", "").split(":")[0];
|
|
|
- // this.sendMessage("ip[" + this.ip + "]连接成功");
|
|
|
- log.info("ip[:{}]连接成功", this.ip);
|
|
|
- ExamRecordCacheUtil.setClientWebsocketStatus(recordId, WebsocketStatusEnum.ON_LINE, false);
|
|
|
- ExamRecordCacheUtil.setClientCurrentIp(recordId, this.ip, false);
|
|
|
- ExamRecordCacheUtil.setClientWebsocketId(recordId, this.session.getId(), false);
|
|
|
- Long clientLastSyncTime = System.currentTimeMillis();
|
|
|
- ExamRecordCacheUtil.setClientLastSyncTime(recordId, clientLastSyncTime, false);
|
|
|
- String[] columns = new String[] { ExamRecordFieldEnum.client_websocket_status.name(),
|
|
|
- ExamRecordFieldEnum.client_current_ip.name(), ExamRecordFieldEnum.client_websocket_id.name(),
|
|
|
- ExamRecordFieldEnum.client_last_sync_time.name() };
|
|
|
- Object[] values = new Object[] { WebsocketStatusEnum.ON_LINE, this.ip, this.session.getId(),
|
|
|
- clientLastSyncTime };
|
|
|
- TOeExamRecordService tOeExamRecordService = SpringContextHolder.getBean(TOeExamRecordService.class);
|
|
|
- tOeExamRecordService.dataUpdatesMq(recordId, columns, values);
|
|
|
- tranMap = new HashMap<>();
|
|
|
- tranMap.put("recordId", this.recordId);
|
|
|
- tranMap.put("deviceId", this.deviceId);
|
|
|
- tranMap.put("ip", this.ip);
|
|
|
- this.updateTime = System.currentTimeMillis();
|
|
|
- tranMap.put("updateTime", this.updateTime);
|
|
|
}
|
|
|
|
|
|
/**
|