remove players from rooms when their sockets close

master
Jordan Orelli 4 years ago
parent e8b82f4b3f
commit 683eb5b368

@ -66,6 +66,13 @@ func (p *player) readLoop(c chan Request, conn *websocket.Conn) {
if err != nil {
p.Error("read error: %v", err)
conn.Close()
c <- Request{
From: p.name,
Wants: effect(func(w *world, r *room, p *player, seq int) result {
r.removePlayer(p.name)
return result{}
}),
}
p.stop <- false
return
}

Loading…
Cancel
Save