Browse Source

pref: The pack object should not be created frequently

master
zhengchong 3 years ago
parent
commit
7a164a8dfb
  1. 5
      znet/connection.go

5
znet/connection.go

@ -95,13 +95,14 @@ func (c *Connection) StartReader() {
defer fmt.Println(c.RemoteAddr().String(), "[conn Reader exit!]") defer fmt.Println(c.RemoteAddr().String(), "[conn Reader exit!]")
defer c.Stop() defer c.Stop()
// 创建拆包解包的对象
dp := NewDataPack()
for { for {
select { select {
case <-c.ctx.Done(): case <-c.ctx.Done():
return return
default: default:
// 创建拆包解包的对象
dp := NewDataPack()
//读取客户端的Msg head //读取客户端的Msg head
headData := make([]byte, dp.GetHeadLen()) headData := make([]byte, dp.GetHeadLen())

Loading…
Cancel
Save