mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-10-13 05:23:44 +08:00
代码规范过滤,移除冗余代码,替换掉不推荐的包
This commit is contained in:
@@ -26,13 +26,13 @@ func (server *Server) stopCron() {
|
||||
func (server *Server) startCron() {
|
||||
// 心跳超时检查
|
||||
if gcron.Search(server.getCronKey(consts.TCPCronHeartbeatVerify)) == nil {
|
||||
gcron.AddSingleton(server.Ctx, "@every 300s", func(ctx context.Context) {
|
||||
_, _ = gcron.AddSingleton(server.Ctx, "@every 300s", func(ctx context.Context) {
|
||||
if server.clients == nil {
|
||||
return
|
||||
}
|
||||
for _, client := range server.clients {
|
||||
if client.heartbeat < gtime.Timestamp()-300 {
|
||||
client.Conn.Close()
|
||||
_ = client.Conn.Close()
|
||||
server.Logger.Debugf(server.Ctx, "client heartbeat timeout, close conn. auth:%+v", client.Auth)
|
||||
}
|
||||
}
|
||||
@@ -41,13 +41,13 @@ func (server *Server) startCron() {
|
||||
|
||||
// 认证检查
|
||||
if gcron.Search(server.getCronKey(consts.TCPCronAuthVerify)) == nil {
|
||||
gcron.AddSingleton(server.Ctx, "@every 300s", func(ctx context.Context) {
|
||||
_, _ = gcron.AddSingleton(server.Ctx, "@every 300s", func(ctx context.Context) {
|
||||
if server.clients == nil {
|
||||
return
|
||||
}
|
||||
for _, client := range server.clients {
|
||||
if client.Auth.EndAt.Before(gtime.Now()) {
|
||||
client.Conn.Close()
|
||||
_ = client.Conn.Close()
|
||||
server.Logger.Debugf(server.Ctx, "client auth expired, close conn. auth:%+v", client.Auth)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user