Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websocket disconnect/leave-all-rooms should delete empty rooms as well otherwise rooms hash goes ever growing #862

Merged
merged 1 commit into from
Jan 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions websocket/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,8 @@ func (s *Server) join(roomName string, connID string) {
// LeaveAll kicks out a connection from ALL of its joined rooms
func (s *Server) LeaveAll(connID string) {
s.mu.Lock()
for name, connectionIDs := range s.rooms {
for i := range connectionIDs {
if connectionIDs[i] == connID {
// fire the on room leave connection's listeners
s.connections.get(connID).fireOnLeave(name)
// the connection is inside this room, lets remove it
if i < len(s.rooms[name]) {
s.rooms[name] = append(s.rooms[name][:i], s.rooms[name][i+1:]...)
}
}
}
for name, _ := range s.rooms {
s.leave(name, connID)
}
s.mu.Unlock()
}
Expand Down