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() {
for _, session := range s.sessions {
if time.Now().Add(-30 * time.Second).After(session.lastPacket) {
s.logger.Info("Session timeout", zap.String("Name", session.Name))
logoutPlayer(session)
for {
if s.isShuttingDown {
break
}
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.