Commit f162b052 authored by Steven Allen's avatar Steven Allen

fix: close gracefully

If we send no message, the client gets a 1005. This will send a 1000.
parent 8cca0dbc
......@@ -84,7 +84,11 @@ func (c *Conn) Write(b []byte) (n int, err error) {
func (c *Conn) Close() error {
var err error
c.closeOnce.Do(func() {
err1 := c.Conn.WriteControl(ws.CloseMessage, nil, time.Now().Add(GracefulCloseTimeout))
err1 := c.Conn.WriteControl(
ws.CloseMessage,
ws.FormatCloseMessage(ws.CloseNormalClosure, "closed"),
time.Now().Add(GracefulCloseTimeout),
)
err2 := c.Conn.Close()
switch {
case err1 != nil:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment