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 | 10 ++++++---- 1 files changed, 6 insertions(+), 4 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 009af79..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,6 +1,6 @@ package com.ruoyi.system.websocket; -import com.ruoyi.system.api.util.WebSocketUsers; +import com.ruoyi.common.core.utils.JwtUtils; import java.util.concurrent.Semaphore; import javax.websocket.OnClose; import javax.websocket.OnError; @@ -19,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); @@ -27,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); @@ -37,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