mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 11:06:27 +01:00
use websocket#Server##leave
inside the websocket#Server##LeaveAll
- fixes delete room when LeaveAll and room is totally empty by @akirahofrom akiraho/master
Former-commit-id: 1e5e1707ae39bf82353ebe13f9b7897b067a087f
This commit is contained in:
commit
c541657d44
|
@ -259,17 +259,8 @@ func (s *Server) join(roomName string, connID string) {
|
||||||
// LeaveAll kicks out a connection from ALL of its joined rooms
|
// LeaveAll kicks out a connection from ALL of its joined rooms
|
||||||
func (s *Server) LeaveAll(connID string) {
|
func (s *Server) LeaveAll(connID string) {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
for name, connectionIDs := range s.rooms {
|
for name, _ := range s.rooms {
|
||||||
for i := range connectionIDs {
|
s.leave(name, connID)
|
||||||
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:]...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user