1
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
昔念
2026-02-11 11:58:34 +08:00
parent 7441a9a88f
commit 0f914eb9b8
3 changed files with 9 additions and 2 deletions

View File

@@ -22,6 +22,8 @@ var ctx = context.TODO()
type Cmd struct {
Func reflect.Value //方法函数
Req reflect.Type //请求体
// 新增预缓存的req创建函数返回结构体指针
NewReqFunc func() interface{}
//Res reflect.Value //返回体
}

View File

@@ -89,9 +89,15 @@ func Init(isGame bool) {
cmdInfo := cool.Cmd{
Func: methodValue,
Req: methodValue.Type().In(0).Elem(),
// Res: , // TODO 待实现对不同用户初始化方法以取消全局cmdcache
}
// 获取req的实际类型如ReqLogin
reqType := reflect.TypeOf(cmdInfo.Req).Elem()
// 预编译创建req实例的函数返回结构体指针
cmdInfo.NewReqFunc = func() interface{} {
return reflect.New(reqType).Interface()
}
cool.CmdCache[cmd] = cmdInfo
// if exists { // 方法已存在
// glog.Error(context.Background(), "命令处理方法已存在,跳过注册", cmd, method.Name)

View File

@@ -61,7 +61,6 @@ func (h *ClientData) OnEvent(data common.TomeeHeader) {
} else {
cool.Logger.Error(context.TODO(), "panic 错误:", err)
}
cool.Logger.Error(context.TODO(), "Recv 错误:", err)
}
}()