feat 优化网络库
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user