websocket disconnect/leave-all-rooms should delete empty rooms as well otherwise rooms hash goes ever growing #862
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
websocket/server.leave() already has the code to remove a connection from the room, and in case it's the last connection in the room then also remove the room from the server rooms hash table.
however websocket/server.LeaveAll() duplicated the code to remove the connection from the room but without removing the room itself from the hash table if it's then empty. note that with the current architecture the rooms hash isn't used just for rooms but it's for every single websocket connection as well. so this makes the rooms hash ever growing with every connection and re-connection. (a hash key pointing to an empty array value)
this commit is to simply re-use server.leave() from server.LeaveAll(), it already fixes the ever-growing-hash issue.