Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
lixizan committed Jan 6, 2023
1 parent 5009697 commit 625c577
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 2 additions & 0 deletions protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions updrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 625c577

Please sign in to comment.