fix invalidateSessions

This commit is contained in:
wish
2025-02-27 20:06:05 +11:00
parent 5028355cfc
commit 3c0d29ed41

View File

@@ -280,13 +280,18 @@ func (s *Server) manageSessions() {
} }
func (s *Server) invalidateSessions() { func (s *Server) invalidateSessions() {
for _, session := range s.sessions { for {
if time.Now().Add(-30 * time.Second).After(session.lastPacket) { if s.isShuttingDown {
s.logger.Info("Session timeout", zap.String("Name", session.Name)) break
logoutPlayer(session)
} }
for _, sess := range s.sessions {
if time.Now().Sub(sess.lastPacket) > time.Second*time.Duration(30) {
s.logger.Info("session timeout", zap.String("Name", sess.Name))
logoutPlayer(sess)
}
}
time.Sleep(time.Second * 10)
} }
time.Sleep(30 * time.Second)
} }
// BroadcastMHF queues a MHFPacket to be sent to all sessions. // BroadcastMHF queues a MHFPacket to be sent to all sessions.