Ensure connection is closed after group cancel for safety

This commit is contained in:
zikaeroh 2020-06-12 21:21:56 -07:00
parent c16062ae40
commit 1aa3073540
1 changed files with 5 additions and 0 deletions

View File

@ -266,6 +266,11 @@ func (r *Room) HandleConn(playerID uuid.UUID, nickname string, c *websocket.Conn
r.sendAll()
}()
g.Go(func() error {
<-ctx.Done()
return c.Close(websocket.StatusGoingAway, "going away")
})
g.Go(func() error {
ticker := time.NewTicker(time.Minute)
defer ticker.Stop()