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

This commit is contained in:
昔念
2026-02-14 03:05:51 +08:00
parent 7cdf7a0890
commit 06b77d598e
15 changed files with 102 additions and 59 deletions

View File

@@ -29,9 +29,9 @@ type Cmd struct {
var CmdCache = make(map[uint32]Cmd, 0)
var (
Logger = glog.New()
Cron = cronex.New() //时间轮
Logger = glog.New()
Cron = cronex.New() //时间轮
Connected int64
)
var Filter *sensitive.Manager
var DefaultGenerator = utils.NewGen(time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC), uint8(Config.GameOnlineID))

View File

@@ -81,7 +81,7 @@ func (s *Server) OnClose(c gnet.Conn, err error) (action gnet.Action) {
// // go s.tempBlockIP(remoteIP, 5*time.Minute)
// }
//fmt.Println(err, c.RemoteAddr().String(), "断开连接")
atomic.AddInt64(&s.connected, -1)
atomic.AddInt64(&cool.Connected, -1)
//logging.Infof("conn[%v] disconnected", c.RemoteAddr().String())
v, _ := c.Context().(*player.ClientData)
@@ -97,7 +97,7 @@ func (s *Server) OnClose(c gnet.Conn, err error) (action gnet.Action) {
return
}
func (s *Server) OnTick() (delay time.Duration, action gnet.Action) {
g.Log().Async().Info(context.Background(), gtime.Now().ISO8601(), "服务器ID", cool.Config.ServerInfo.OnlineID, "链接数", atomic.LoadInt64(&s.connected))
g.Log().Async().Info(context.Background(), gtime.Now().ISO8601(), "服务器ID", cool.Config.ServerInfo.OnlineID, "链接数", atomic.LoadInt64(&cool.Connected))
// if s.quit && atomic.LoadInt64(&s.connected) == 0 {
// //执行正常退出逻辑
// os.Exit(0)
@@ -120,7 +120,7 @@ func (s *Server) OnOpen(conn gnet.Conn) (out []byte, action gnet.Action) {
conn.SetContext(player.NewClientData(conn)) //注入data
}
atomic.AddInt64(&s.connected, 1)
atomic.AddInt64(&cool.Connected, 1)
return nil, gnet.None
}

View File

@@ -13,9 +13,9 @@ type Handler interface {
}
type Server struct {
gnet.BuiltinEventEngine
eng gnet.Engine
addr string
connected int64
eng gnet.Engine
addr string
network string
multicore bool
bufferSize int