From 01d6fa48a0de7a21988e89f71721b6b85e53b517 Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期四, 06 三月 2025 16:33:53 +0800 Subject: [PATCH] 去掉资讯图片必填限制 --- ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/websocket/WebSocketServer.java | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/websocket/WebSocketServer.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/websocket/WebSocketServer.java index ee679e8..edd6125 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/websocket/WebSocketServer.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/websocket/WebSocketServer.java @@ -1,5 +1,6 @@ package com.ruoyi.system.websocket; +import com.ruoyi.common.core.utils.JwtUtils; import java.util.concurrent.Semaphore; import javax.websocket.OnClose; import javax.websocket.OnError; @@ -18,7 +19,7 @@ * @作者 ruoyi */ @Component -@ServerEndpoint("/websocket/message/{clientType}") +@ServerEndpoint("/websocket/message/{clientType}/{accessToken}") public class WebSocketServer { private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketServer.class); @@ -26,7 +27,8 @@ private static Semaphore socketSemaphore = new Semaphore(socketMaxOnlineCount); @OnOpen - public void onOpen(Session session, @PathParam("clientType") Integer clientType) + public void onOpen(Session session, @PathParam("clientType") Integer clientType, + @PathParam("accessToken") String accessToken) throws Exception { boolean semaphoreFlag = false; semaphoreFlag = SemaphoreUtils.tryAcquire(socketSemaphore); @@ -36,7 +38,8 @@ "当前在线人数超过限制数:" + socketMaxOnlineCount); session.close(); } else { - WebSocketUsers.put(session.getId(), session, clientType); + String userId = JwtUtils.getUserId(accessToken); + WebSocketUsers.put(session.getId(), session, clientType, Long.parseLong(userId)); if (clientType == 1) { LOGGER.info("\n 用户端建立连接 - {}", session); -- Gitblit v1.7.1