diff --git a/compress.go b/compress.go index 1d02cdd2..50fc5ab0 100644 --- a/compress.go +++ b/compress.go @@ -24,7 +24,7 @@ type compressor struct { // Compress 压缩 func (c *compressor) Compress(content []byte) ([]byte, error) { - if c.writeBuffer.Cap() > internal.Lv3 { + if c.writeBuffer.Cap() > internal.Lv4 { c.writeBuffer = internal.NewBuffer(nil) } diff --git a/protocol.go b/protocol.go index 3c3a684a..1a5f40e2 100644 --- a/protocol.go +++ b/protocol.go @@ -15,6 +15,8 @@ func (c Opcode) IsDataFrame() bool { return c <= OpcodeBinary } +// WebSocket Event +// OnError and OnClose will not both be called type Event interface { OnOpen(socket *Conn) OnError(socket *Conn, err error) diff --git a/updrader.go b/updrader.go index 973bd3b5..3a4e34cb 100644 --- a/updrader.go +++ b/updrader.go @@ -69,6 +69,7 @@ func handshake(conn net.Conn, headers http.Header, websocketKey string) error { } // Accept http protocol upgrade to websocket +// ctx done means server stopping func Accept(ctx context.Context, w http.ResponseWriter, r *http.Request, eventHandler Event, config Config) (*Conn, error) { config.initialize()