系统优化

This commit is contained in:
hahwu 2025-01-23 17:05:48 +08:00
parent 33ce4eba43
commit f7a9ab3be1

View File

@ -1,6 +1,7 @@
package game
import (
"context"
"reflect"
"server/GoUtil"
"server/MergeConst"
@ -48,8 +49,23 @@ func HandleAdminReq(args []interface{}) {
// log.Debug("admin 消息Func : %s", m.GetFunc())
AdminProcess(m.GetFunc(), []interface{}{a, buf})
}
func HandleClientReq(args []interface{}) {
// log.Debug("HandleClientReq")
// 创建一个带有超时的上下文
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
done := make(chan struct{})
go HandleClientReqProcess(args)
select {
case <-ctx.Done():
m := args[0].(*msg.ClientReq)
log.Debug("HandleClientReq func %s timed out", m.GetFunc())
case <-done:
log.Debug("HandleClientReq completed")
}
}
func HandleClientReqProcess(args []interface{}) {
if G_GameLogicPtr.SeverInfo.Status == SERVER_STATUS_CLOSE || G_GameLogicPtr.SeverInfo.Status == SERVER_STATUS_MAINTAIN {
return // 服务器关闭或者维护中,不处理任何消息
}