From 969d444b894dca2e38e54e8280a128fc2f416572 Mon Sep 17 00:00:00 2001 From: bigtian <7990497@qq.com> Date: Tue, 22 Oct 2024 16:19:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(namespace):=20=E9=81=BF=E5=85=8D=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF=E9=87=8D=E5=A4=8D=E8=BF=9E=E6=8E=A5=E5=88=B0?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 onConnect 方法中添加检查,防止客户端重复加入同一个命名空间 - 优化了命名空间连接逻辑,提高了系统稳定性 --- .../com/corundumstudio/socketio/namespace/Namespace.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/corundumstudio/socketio/namespace/Namespace.java b/src/main/java/com/corundumstudio/socketio/namespace/Namespace.java index cb5e9842..cd78123c 100644 --- a/src/main/java/com/corundumstudio/socketio/namespace/Namespace.java +++ b/src/main/java/com/corundumstudio/socketio/namespace/Namespace.java @@ -200,6 +200,11 @@ public void addConnectListener(ConnectListener listener) { } public void onConnect(SocketIOClient client) { + if (roomClients.containsKey(getName()) && + roomClients.get(getName()).contains(client.getSessionId())) { + return; + } + join(getName(), client.getSessionId()); storeFactory.pubSubStore().publish(PubSubType.JOIN, new JoinLeaveMessage(client.getSessionId(), getName(), getName()));