Browse Source

Send close message when explicitly closing client.

pull/115/head
Joachim Bauch 2 weeks ago
parent
commit
2628735431
No known key found for this signature in database GPG Key ID: 77C1D22D53E15F02
  1. 6
      client.go

6
client.go

@ -184,6 +184,12 @@ func (c *Client) Close() {
return
}
c.mu.Lock()
if c.conn != nil {
c.conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "")) // nolint
}
c.mu.Unlock()
if atomic.LoadUint32(&c.messageProcessing) == 1 {
// Defer closing
atomic.StoreUint32(&c.closed, 2)

Loading…
Cancel
Save