1
This commit is contained in:
@@ -2,20 +2,23 @@ package handler
|
||||
|
||||
import (
|
||||
"blazing/common/serialize/bytearray"
|
||||
|
||||
"github.com/panjf2000/gnet/v2"
|
||||
)
|
||||
|
||||
// TomeeHeader 结构体字段定义
|
||||
type TomeeHeader struct {
|
||||
Len uint32 `json:"len"`
|
||||
Version string `json:"version"`
|
||||
UserID uint32 `json:"userId"`
|
||||
Error uint32 `json:"error"`
|
||||
CMDID uint32 `json:"cmdId"`
|
||||
Result uint32 `json:"result"`
|
||||
Data []byte `json:"data"`
|
||||
UserID uint32 `json:"userId"`
|
||||
//Error uint32 `json:"error" struc:"[0]pad"`
|
||||
|
||||
Result uint32 `json:"result"`
|
||||
Data []byte `json:"data" struc:"[0]pad"` //组包忽略此字段
|
||||
}
|
||||
type TomeeHandler struct {
|
||||
Callback func(data TomeeHeader)
|
||||
Callback func(conn gnet.Conn, data TomeeHeader)
|
||||
}
|
||||
|
||||
func NewTomeeHandler() *TomeeHandler {
|
||||
@@ -23,7 +26,7 @@ func NewTomeeHandler() *TomeeHandler {
|
||||
}
|
||||
|
||||
// Handle entry receiver
|
||||
func (h *TomeeHandler) Handle(data []byte) { //处理接收到的数据 ,
|
||||
func (h *TomeeHandler) Handle(c gnet.Conn, data []byte) { //处理接收到的数据 ,
|
||||
//fmt.Println("接收数据", data)
|
||||
|
||||
header := TomeeHeader{}
|
||||
@@ -37,6 +40,6 @@ func (h *TomeeHandler) Handle(data []byte) { //处理接收到的数据 ,
|
||||
header.Result, _ = tempdata.ReadUInt32()
|
||||
header.Data = tempdata.BytesAvailable()
|
||||
//fmt.Println("接收封包", header)
|
||||
h.Callback(header)
|
||||
h.Callback(c, header)
|
||||
//return header
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user