Skip to content

Commit

Permalink
重构:bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
guonaihong committed Jun 25, 2023
1 parent 989c75a commit e6394eb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (c *Conn) readLoop() error {

var fragmentFrameBuf []byte
var headArray [maxFrameHeaderSize]byte

for {

// 从网络读取数据
Expand Down Expand Up @@ -160,7 +161,7 @@ func (c *Conn) readLoop() error {
}

c.Callback.OnMessage(c, fragmentFrameHeader.opcode, fragmentFrameBuf)
fragmentFrameHeader = nil
fragmentFrameBuf = fragmentFrameBuf[0:0]
fragmentFrameHeader = nil
}
continue
Expand All @@ -176,7 +177,7 @@ func (c *Conn) readLoop() error {
if !f.fin {
prevFrame := f.frameHeader
// 第一次分段
if fragmentFrameBuf == nil {
if len(fragmentFrameBuf) == 0 {
fragmentFrameBuf = append(fragmentFrameBuf, f.payload...)
f.payload = nil
}
Expand Down

0 comments on commit e6394eb

Please sign in to comment.