TcpService新增设置内存池接口

This commit is contained in:
boyce
2020-12-14 16:05:32 +08:00
parent e25eda14d1
commit 4796ad7404
8 changed files with 41 additions and 16 deletions

View File

@@ -23,6 +23,7 @@ type JsonProcessor struct {
unknownMessageHandler UnknownMessageJsonHandler
connectHandler ConnectJsonHandler
disconnectHandler ConnectJsonHandler
network.INetMempool
}
type JsonPackInfo struct {
@@ -33,6 +34,8 @@ type JsonPackInfo struct {
func NewJsonProcessor() *JsonProcessor {
processor := &JsonProcessor{mapMsg:map[uint16]MessageJsonInfo{}}
processor.INetMempool = network.NewMemAreaPool()
return processor
}
@@ -54,7 +57,7 @@ func (jsonProcessor *JsonProcessor ) MsgRoute(msg interface{},userdata interface
func (jsonProcessor *JsonProcessor) Unmarshal(data []byte) (interface{}, error) {
typeStruct := struct {Type int `json:"typ"`}{}
defer network.ReleaseByteSlice(data)
defer jsonProcessor.ReleaseByteSlice(data)
err := json.Unmarshal(data, &typeStruct)
if err != nil {
return nil, err