diff --git a/src/main/java/club/joylink/rtss/simulation/messaging/websocket/DefaultSubscribeManager.java b/src/main/java/club/joylink/rtss/simulation/messaging/websocket/DefaultSubscribeManager.java index 5237a4a67..38240faa6 100644 --- a/src/main/java/club/joylink/rtss/simulation/messaging/websocket/DefaultSubscribeManager.java +++ b/src/main/java/club/joylink/rtss/simulation/messaging/websocket/DefaultSubscribeManager.java @@ -18,12 +18,12 @@ import java.util.concurrent.ConcurrentHashMap; @Slf4j @Component public class DefaultSubscribeManager { - /** - * 暂时限制一个token只能对应一个wsSessionId - * k - token - * v - wsSessionId - */ - public static final Map tokenSessionMap = new ConcurrentHashMap<>(); +// /** +// * 暂时限制一个token只能对应一个wsSessionId +// * k - token +// * v - wsSessionId +// */ +// public static final Map tokenSessionMap = new ConcurrentHashMap<>(); /** * key-wsSessionId * val-simulationId @@ -44,11 +44,11 @@ public class DefaultSubscribeManager { public void disconnect(WebsocketConfig.MyPrincipal user, String wsSessionId) { if (wsSessionId == null) return; - String token = user.getToken(); - String connectedSession = tokenSessionMap.get(token); - if (wsSessionId.equals(connectedSession)) { //当前的sessionId和要断开的一致 - tokenSessionMap.remove(token); - } +// String token = user.getToken(); +// String connectedSession = tokenSessionMap.get(token); +// if (wsSessionId.equals(connectedSession)) { //当前的sessionId和要断开的一致 +// tokenSessionMap.remove(token); +// } String sid = wsSidMap.remove(wsSessionId); if (sid == null) { return; @@ -66,13 +66,13 @@ public class DefaultSubscribeManager { } public synchronized void subscribe(WebsocketConfig.MyPrincipal user, String wsSessionId, String subId, String destination) { - String token = user.getToken(); - String oldSession = tokenSessionMap.get(token); - if (!wsSessionId.equals(oldSession)) { //一个token出现多次连接 - disconnect(user, oldSession); //断开旧连接 - } - - tokenSessionMap.put(token, wsSessionId); //记录新连接 +// String token = user.getToken(); +// String oldSession = tokenSessionMap.get(token); +// if (!wsSessionId.equals(oldSession)) { //一个token出现多次连接 +// disconnect(user, oldSession); //断开旧连接 +// } +// +// tokenSessionMap.put(token, wsSessionId); //记录新连接 if (destination.startsWith("/user")) { destination = destination.substring(5); }