Skip to content

Commit 9f30495

Browse files
committed
fix: notify clients and clean up on host disconnect
Ensure clients are notified when the host disconnects and remove all listeners to prevent memory leaks
1 parent 8352e86 commit 9f30495

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@ io.on('connection', (socket) => {
9191
for (const [roomId, room] of rooms.entries()) {
9292
if (room.host === socket.id) {
9393
rooms.delete(roomId);
94+
// Notify all clients in the room
95+
io.to(roomId).emit('host-disconnected');
9496
break;
9597
}
9698
}
99+
// Clean up any remaining references
100+
socket.removeAllListeners();
97101
});
98102
});
99103

0 commit comments

Comments
 (0)