|
@@ -56,13 +56,11 @@ public class WebSocketServerEndpoint {
|
|
|
@OnOpen
|
|
|
public void onOpen(Session session, @PathParam("path") String path) {
|
|
|
long amount = counter.incrementAndGet();
|
|
|
-
|
|
|
this.sessionId = UUID.randomUUID().toString().replace("-", "");
|
|
|
-
|
|
|
ThreadContext.put("TRACE_ID", sessionId);
|
|
|
|
|
|
- if (LOG.isDebugEnabled()) {
|
|
|
- LOG.debug("[onOpen]. path=" + path + "; sessionsAmount=" + amount);
|
|
|
+ if (LOG.isInfoEnabled()) {
|
|
|
+ LOG.info("[onOpen] into... path={} curSessionSize={}", path, amount);
|
|
|
}
|
|
|
|
|
|
MessageOut out = new MessageOut(path, sessionId);
|
|
@@ -106,6 +104,10 @@ public class WebSocketServerEndpoint {
|
|
|
|
|
|
ThreadContext.put("CALLER", user.getKey());
|
|
|
|
|
|
+ if (LOG.isInfoEnabled()) {
|
|
|
+ LOG.info("[onOpen] sendText... path={} curSessionSize={} user={}", path, amount, user.getKey());
|
|
|
+ }
|
|
|
+
|
|
|
WebSocketHelper.sendText(session, path, out);
|
|
|
|
|
|
WebSocketHelper.setSession(path, user, session, sessionId);
|
|
@@ -132,18 +134,22 @@ public class WebSocketServerEndpoint {
|
|
|
|
|
|
@OnClose
|
|
|
public void onClose(Session session, @PathParam("path") String path) {
|
|
|
-
|
|
|
long amount = counter.decrementAndGet();
|
|
|
|
|
|
+ String user = "";
|
|
|
SessionInfo sessionInfo = WebSocketHelper.getSessionInfo(session);
|
|
|
if (null != sessionInfo) {
|
|
|
+ user = sessionInfo.getUser().getKey();
|
|
|
ThreadContext.put("TRACE_ID", sessionInfo.getSessionId());
|
|
|
- ThreadContext.put("CALLER", sessionInfo.getUser().getKey());
|
|
|
+ ThreadContext.put("CALLER", user);
|
|
|
} else {
|
|
|
ThreadContext.put("TRACE_ID", this.sessionId);
|
|
|
}
|
|
|
|
|
|
- LOG.debug("[onClose]. path=" + path + "; sessionsAmount=" + amount);
|
|
|
+ if (LOG.isInfoEnabled()) {
|
|
|
+ LOG.info("[onClose] path={} curSessionSize={} user={}", path, amount, user);
|
|
|
+ }
|
|
|
+
|
|
|
WebSocketHelper.closeSession(session);
|
|
|
}
|
|
|
|
|
@@ -165,8 +171,8 @@ public class WebSocketServerEndpoint {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (LOG.isDebugEnabled()) {
|
|
|
- LOG.debug("[onMessage]. path=" + path + ". message=" + message);
|
|
|
+ if (LOG.isInfoEnabled()) {
|
|
|
+ LOG.info("[onMessage] path={} user={}", path, sessionInfo.getUser().getKey());
|
|
|
}
|
|
|
|
|
|
SessionInfo si = WebSocketHelper.getSessionInfo(session);
|
|
@@ -242,16 +248,18 @@ public class WebSocketServerEndpoint {
|
|
|
|
|
|
@OnError
|
|
|
public void onError(Session session, @PathParam("path") String path, Throwable t) {
|
|
|
-
|
|
|
+ String user = "";
|
|
|
SessionInfo sessionInfo = WebSocketHelper.getSessionInfo(session);
|
|
|
if (null != sessionInfo) {
|
|
|
+ user = sessionInfo.getUser().getKey();
|
|
|
ThreadContext.put("TRACE_ID", sessionInfo.getSessionId());
|
|
|
- ThreadContext.put("CALLER", sessionInfo.getUser().getKey());
|
|
|
+ ThreadContext.put("CALLER", user);
|
|
|
} else {
|
|
|
ThreadContext.put("TRACE_ID", this.sessionId);
|
|
|
}
|
|
|
|
|
|
- LOG.error("[onError]. path=" + path, t);
|
|
|
+ LOG.error("[onError] path={} user={} ", path, user, t);
|
|
|
+
|
|
|
WebSocketHelper.closeSession(session);
|
|
|
}
|
|
|
|