Skip to content

Commit

Permalink
fix(namespace): 避免客户端重复连接到命名空间
Browse files Browse the repository at this point in the history
- 在 onConnect 方法中添加检查,防止客户端重复加入同一个命名空间
- 优化了命名空间连接逻辑,提高了系统稳定性
  • Loading branch information
bigtian99 committed Oct 22, 2024
1 parent c4ca71e commit 969d444
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand Down

0 comments on commit 969d444

Please sign in to comment.