diff --git a/ws/client.go b/ws/client.go index b09dc2c..ff24278 100644 --- a/ws/client.go +++ b/ws/client.go @@ -157,7 +157,9 @@ func clientReader(c *client){ msgErr := msg.check(frag != nil) // fmt.Printf("> %.3f us\n", float64(time.Now().UnixNano()-s0)/1e3) - if msgErr == ErrInvalidPayload { + if msgErr == CloseFrame { + break + } else if msgErr == ErrInvalidPayload { closeStatus = INVALID_PAYLOAD break } else if msgErr != nil { @@ -300,7 +302,7 @@ func (c *client) close(status MessageError, clientACK bool){ /* (4) Send message */ msg.Send(c.io.sock) // if err != nil { - // fmt.Printf("[close] send error (%s0\n", err) + // fmt.Printf("[close] send error (%s0\n", err) // } } diff --git a/ws/message.go b/ws/message.go index 6cb54f9..26f5404 100644 --- a/ws/message.go +++ b/ws/message.go @@ -14,6 +14,7 @@ var ErrInvalidSize = fmt.Errorf("Received invalid payload size") var ErrInvalidPayload = fmt.Errorf("Received invalid utf8 payload") var ErrInvalidCloseStatus = fmt.Errorf("Received invalid close status") var ErrInvalidOpCode = fmt.Errorf("Received invalid OpCode") +var CloseFrame = fmt.Errorf("Received close Frame") // Maximum Header Size = Final/OpCode + isMask/Length + Length + Mask @@ -291,7 +292,7 @@ func (m *Message) check(fragment bool) error{ return ErrInvalidCloseStatus } } - return nil + return CloseFrame case PING: return nil