mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
websocket disconnect/leave-all-rooms should delete empty rooms as well otherwise rooms hash goes ever growing
Former-commit-id: 7f228be67cab79fc34f4a5a6a8b41b6ba8330186
This commit is contained in:
parent
10714273e9
commit
5157ed17a6
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user