Skip to content

Commit

Permalink
Merge pull request #928 from ksahu750/bulk-leave-on-disconnect
Browse files Browse the repository at this point in the history
Send Bulk leave event instead of multiple leave events on disconnect
  • Loading branch information
mrniko authored Jan 23, 2024
2 parents 640617d + 6aa74dc commit 07d36f0
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,14 @@ public void addDisconnectListener(DisconnectListener listener) {
public void onDisconnect(SocketIOClient client) {
Set<String> joinedRooms = client.getAllRooms();
allClients.remove(client.getSessionId());
final Set<String> roomsToLeave = new HashSet<>(joinedRooms);

// client must leave all rooms and publish the leave msg one by one on disconnect.
for (String joinedRoom : joinedRooms) {
leave(roomClients, joinedRoom, client.getSessionId());
storeFactory.pubSubStore().publish(PubSubType.LEAVE, new JoinLeaveMessage(client.getSessionId(), joinedRoom, getName()));
}
clientRooms.remove(client.getSessionId());
storeFactory.pubSubStore().publish(PubSubType.BULK_LEAVE, new BulkJoinLeaveMessage(client.getSessionId(), roomsToLeave, getName()));

try {
for (DisconnectListener listener : disconnectListeners) {
Expand Down

0 comments on commit 07d36f0

Please sign in to comment.