diff --git a/ws/client.go b/ws/client.go index 38fd34c..2561085 100644 --- a/ws/client.go +++ b/ws/client.go @@ -173,9 +173,11 @@ func clientReader(c *client){ /* (6) Send PONG */ if msg.Type == PING { // fmt.Printf("[reader] PING -> PONG\n") - msg.Final = true - msg.Type = PONG - c.ch.send <- *msg + if c.io.writing { + msg.Final = true + msg.Type = PONG + c.ch.send <- *msg + } continue } @@ -280,8 +282,6 @@ func (c *client) close(status MessageError, clientACK bool){ Data: make([]byte, 2), } binary.BigEndian.PutUint16(msg.Data, uint16(status)) - // msg.Data = append(msg.Data, []byte("(closing)")...) - msg.Size = uint( len(msg.Data) ) /* (4) Send message */ err := msg.Send(c.io.sock)