MCPcopy Index your code
hub / github.com/screego/server / executeNoError

Method executeNoError

ws/event_disconnected.go:20–77  ·  view source on GitHub ↗
(rooms *Rooms, current ClientInfo)

Source from the content-addressed store, hash-verified

18}
19
20func (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}

Callers 2

ExecuteMethod · 0.95
StartMethod · 0.95

Calls 6

EndShareTypeAlias · 0.92
writeTimeoutFunction · 0.85
WriteTimeoutMethod · 0.80
closeSessionMethod · 0.80
closeRoomMethod · 0.80
notifyInfoChangedMethod · 0.80

Tested by

no test coverage detected