refactor(logic): 重构逻辑模块
- 移除了 player.go 中的 SendPackBytes 方法 - 将 TomeeHeader 中的 CMDID 改为 CMD,类型从 uint32 改为 EnumCommandID - 删除了 controller 文件夹下的 service.go 和 login.go - 新增了 login 文件夹下的 PlayerLoginService.go - 优化了 main.go 中的 Start 函数,使用 controller.Recv 作为回调
This commit is contained in:
@@ -9,13 +9,13 @@ import (
|
||||
// TomeeHeader 结构体字段定义
|
||||
type TomeeHeader struct {
|
||||
Len uint32 `json:"len"`
|
||||
Version string `json:"version"`
|
||||
CMDID uint32 `json:"cmdId"`
|
||||
Version string `json:"version" struc:"[1]byte"`
|
||||
CMD uint32 `json:"cmdId"`
|
||||
UserID uint32 `json:"userId"`
|
||||
//Error uint32 `json:"error" struc:"[0]pad"`
|
||||
|
||||
Result uint32 `json:"result"`
|
||||
Data []byte `json:"data" struc:"[0]pad"` //组包忽略此字段
|
||||
Data []byte `json:"data"` //组包忽略此字段// struc:"[0]pad"
|
||||
}
|
||||
type TomeeHandler struct {
|
||||
Callback func(conn gnet.Conn, data TomeeHeader)
|
||||
@@ -34,7 +34,7 @@ func (h *TomeeHandler) Handle(c gnet.Conn, data []byte) { //处理接收到的
|
||||
tempdata := bytearray.CreateByteArray(data)
|
||||
header.Len, _ = tempdata.ReadUInt32()
|
||||
header.Version, _ = tempdata.ReadString(1)
|
||||
header.CMDID, _ = tempdata.ReadUInt32()
|
||||
header.CMD, _ = tempdata.ReadUInt32()
|
||||
header.UserID, _ = tempdata.ReadUInt32()
|
||||
|
||||
header.Result, _ = tempdata.ReadUInt32()
|
||||
|
||||
Reference in New Issue
Block a user