Skip to content

Commit

Permalink
use websocket#Server##leave inside the websocket#Server##LeaveAll
Browse files Browse the repository at this point in the history
… - fixes delete room when LeaveAll and room is totally empty by @akirahofrom akiraho/master
  • Loading branch information
kataras authored Jan 5, 2018
2 parents 8c4e17c + 18cf64a commit 07d5c74
Showing 1 changed file with 2 additions and 11 deletions.
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

0 comments on commit 07d5c74

Please sign in to comment.