feat 优化网络库

This commit is contained in:
2026-01-03 13:19:43 +08:00
parent a565692217
commit 470f642515
19 changed files with 180 additions and 126 deletions

View File

@@ -6,6 +6,7 @@ import (
"google.golang.org/protobuf/proto"
"math"
"math/rand"
"sync"
"time"
)
@@ -49,14 +50,21 @@ func (_ *EnterInstance) Handle(data []byte, client *Client) {
}()
}
var s2cPositionPool = sync.Pool{
New: func() interface{} {
return &sc_pb.Message{}
},
}
type Position struct {
}
func (_ *Position) Handle(data []byte, client *Client) {
msg := &sc_pb.S2C_Position{}
if err := proto.Unmarshal(data, msg); err != nil {
log.Errorf("handle msg error")
client.Stop()
return
}
//msg := s2cPositionPool.Get().(*sc_pb.Message)
//if err := proto.Unmarshal(data, msg); err != nil {
// log.Errorf("handle msg error")
// client.Stop()
// return
//}
//s2cPositionPool.Put(msg)
}