(rooms *Rooms, current ClientInfo)
| 18 | } |
| 19 | |
| 20 | func (e *Disconnected) executeNoError(rooms *Rooms, current ClientInfo) { |
| 21 | roomID := rooms.connected[current.ID] |
| 22 | delete(rooms.connected, current.ID) |
| 23 | writeTimeout[outgoing.Message](current.Write, outgoing.CloseWriter{Code: e.Code, Reason: e.Reason}) |
| 24 | |
| 25 | if roomID == "" { |
| 26 | return |
| 27 | } |
| 28 | |
| 29 | room, ok := rooms.Rooms[roomID] |
| 30 | if !ok { |
| 31 | // room may already be removed |
| 32 | return |
| 33 | } |
| 34 | |
| 35 | user, ok := room.Users[current.ID] |
| 36 | |
| 37 | if !ok { |
| 38 | // room may already be removed |
| 39 | return |
| 40 | } |
| 41 | |
| 42 | delete(room.Users, current.ID) |
| 43 | usersLeftTotal.Inc() |
| 44 | |
| 45 | for id, session := range room.Sessions { |
| 46 | if bytes.Equal(session.Client.Bytes(), current.ID.Bytes()) { |
| 47 | host, ok := room.Users[session.Host] |
| 48 | if ok { |
| 49 | host.WriteTimeout(outgoing.EndShare(id)) |
| 50 | } |
| 51 | room.closeSession(rooms, id) |
| 52 | } |
| 53 | if bytes.Equal(session.Host.Bytes(), current.ID.Bytes()) { |
| 54 | client, ok := room.Users[session.Client] |
| 55 | if ok { |
| 56 | client.WriteTimeout(outgoing.EndShare(id)) |
| 57 | } |
| 58 | room.closeSession(rooms, id) |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | if user.Owner && room.CloseOnOwnerLeave { |
| 63 | for _, member := range room.Users { |
| 64 | delete(rooms.connected, member.ID) |
| 65 | member.WriteTimeout(outgoing.CloseWriter{Code: websocket.CloseNormalClosure, Reason: CloseOwnerLeft}) |
| 66 | } |
| 67 | rooms.closeRoom(roomID) |
| 68 | return |
| 69 | } |
| 70 | |
| 71 | if len(room.Users) == 0 { |
| 72 | rooms.closeRoom(roomID) |
| 73 | return |
| 74 | } |
| 75 | |
| 76 | room.notifyInfoChanged() |
| 77 | } |
no test coverage detected