|
@@ -19,6 +19,8 @@ import org.apache.commons.collections.CollectionUtils;
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.logging.log4j.ThreadContext;
|
|
import org.apache.logging.log4j.ThreadContext;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.google.gson.JsonElement;
|
|
import com.google.gson.JsonElement;
|
|
@@ -27,8 +29,6 @@ import com.google.gson.JsonSyntaxException;
|
|
|
|
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
-import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
|
|
|
|
-import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
|
|
|
|
import cn.com.qmth.examcloud.commons.util.JsonUtil;
|
|
import cn.com.qmth.examcloud.commons.util.JsonUtil;
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
import cn.com.qmth.examcloud.web.support.SpringContextHolder;
|
|
import cn.com.qmth.examcloud.web.support.SpringContextHolder;
|
|
@@ -44,7 +44,7 @@ import cn.com.qmth.examcloud.web.support.SpringContextHolder;
|
|
@Component
|
|
@Component
|
|
public class WebSocketServerEndpoint {
|
|
public class WebSocketServerEndpoint {
|
|
|
|
|
|
- private static final ExamCloudLog WS_LOG = ExamCloudLogFactory.getLog("WS_LOGGER");
|
|
|
|
|
|
+ private static final Logger LOG = LoggerFactory.getLogger(WebSocketServerEndpoint.class);
|
|
|
|
|
|
private static RedisClient redisClient;
|
|
private static RedisClient redisClient;
|
|
|
|
|
|
@@ -68,8 +68,8 @@ public class WebSocketServerEndpoint {
|
|
|
|
|
|
ThreadContext.put("TRACE_ID", sessionId);
|
|
ThreadContext.put("TRACE_ID", sessionId);
|
|
|
|
|
|
- if (WS_LOG.isDebugEnabled()) {
|
|
|
|
- WS_LOG.debug("[onOpen]. path=" + path + "; sessionsAmount=" + amount);
|
|
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("[onOpen]. path=" + path + "; sessionsAmount=" + amount);
|
|
}
|
|
}
|
|
|
|
|
|
MessageOut out = new MessageOut(path, sessionId);
|
|
MessageOut out = new MessageOut(path, sessionId);
|
|
@@ -87,12 +87,12 @@ public class WebSocketServerEndpoint {
|
|
String token = getRequestParameter(session, "token");
|
|
String token = getRequestParameter(session, "token");
|
|
|
|
|
|
if (StringUtils.isBlank(key)) {
|
|
if (StringUtils.isBlank(key)) {
|
|
- WS_LOG.error("[onOpen-FAIL]. path=" + path + ". key is blank");
|
|
|
|
|
|
+ LOG.error("[onOpen-FAIL]. path=" + path + ". key is blank");
|
|
IOUtils.closeQuietly(session);
|
|
IOUtils.closeQuietly(session);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if (StringUtils.isBlank(token)) {
|
|
if (StringUtils.isBlank(token)) {
|
|
- WS_LOG.error("[onOpen-FAIL]. path=" + path + ". token is blank");
|
|
|
|
|
|
+ LOG.error("[onOpen-FAIL]. path=" + path + ". token is blank");
|
|
IOUtils.closeQuietly(session);
|
|
IOUtils.closeQuietly(session);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -150,7 +150,7 @@ public class WebSocketServerEndpoint {
|
|
ThreadContext.put("TRACE_ID", this.sessionId);
|
|
ThreadContext.put("TRACE_ID", this.sessionId);
|
|
}
|
|
}
|
|
|
|
|
|
- WS_LOG.debug("[onClose]. path=" + path + "; sessionsAmount=" + amount);
|
|
|
|
|
|
+ LOG.debug("[onClose]. path=" + path + "; sessionsAmount=" + amount);
|
|
WebSocketHelper.closeSession(session);
|
|
WebSocketHelper.closeSession(session);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -172,8 +172,8 @@ public class WebSocketServerEndpoint {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (WS_LOG.isDebugEnabled()) {
|
|
|
|
- WS_LOG.debug("[onMessage]. path=" + path + ". message=" + message);
|
|
|
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
|
+ LOG.debug("[onMessage]. path=" + path + ". message=" + message);
|
|
}
|
|
}
|
|
|
|
|
|
SessionInfo si = WebSocketHelper.getSessionInfo(session);
|
|
SessionInfo si = WebSocketHelper.getSessionInfo(session);
|
|
@@ -236,10 +236,10 @@ public class WebSocketServerEndpoint {
|
|
out.setContent(result);
|
|
out.setContent(result);
|
|
|
|
|
|
} catch (StatusException e) {
|
|
} catch (StatusException e) {
|
|
- WS_LOG.error("[onMessage-FAIL]. path=" + path + "", e);
|
|
|
|
|
|
+ LOG.error("[onMessage-FAIL]. path=" + path + "", e);
|
|
out.setStatus(e.getCode(), e.getDesc());
|
|
out.setStatus(e.getCode(), e.getDesc());
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- WS_LOG.error("[onMessage-FAIL]. path=" + path + "", e);
|
|
|
|
|
|
+ LOG.error("[onMessage-FAIL]. path=" + path + "", e);
|
|
out.setStatus("500", "系统异常");
|
|
out.setStatus("500", "系统异常");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -257,7 +257,7 @@ public class WebSocketServerEndpoint {
|
|
ThreadContext.put("TRACE_ID", this.sessionId);
|
|
ThreadContext.put("TRACE_ID", this.sessionId);
|
|
}
|
|
}
|
|
|
|
|
|
- WS_LOG.error("[onError]. path=" + path, t);
|
|
|
|
|
|
+ LOG.error("[onError]. path=" + path, t);
|
|
WebSocketHelper.closeSession(session);
|
|
WebSocketHelper.closeSession(session);
|
|
}
|
|
}
|
|
|
|
|