1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef EGS_SHUTDOWN_HANDLER_H
19 #define EGS_SHUTDOWN_HANDLER_H
21 #include "nel/misc/variable.h"
22 #include "nel/misc/time_nl.h"
24 #include "nel/misc/ucstring.h"
28 * This singleton handles shutdown events
29 * \author Benjamin Legros
30 * \author Nevrax France
33 class CShutdownHandler
37 /// \name Basic Management
53 static void release();
60 /// \name Handler Commands Declaration
64 * Start Shutdown Counter
66 static void startShutdown(sint shutdownCounter
= -1, sint broadcastMessageRate
= -1);
71 static void cancelShutdown();
75 * Actually reset WS ShardOpen variable to OpenForAll
77 static void restartShard();
85 /// \name Info queries
89 * Get current shard state
91 static std::string
getState();
106 static TState _State
;
109 static NLMISC::TTime _ShutdownTimeout
;
112 static NLMISC::TTime _NextBroadcastMessage
;
114 /// ShardOpen has been closed
115 static bool _ShardClosed
;
117 /// Broadcast Message Rate
118 static uint _BroadcastMessageRate
;
120 /// Broadcast Shutdown message
121 static void broadcastShutdownMessage();
123 /// Broadcast message
124 static void broadcastMessage(const ucstring
& message
);
126 /// Disconnect all players
127 static void disconnectPlayers();
131 typedef uint32 TSecTime
; // unit of NLMISC::CTime::getSecondsSince1970()
134 * Handle daily automatic shutdown
136 class CAutomaticShutdownHandler
141 static void update();
143 /// Uses daily shutdown sequence time to compute next time
144 static void computePlannedShutdownTimes( NLMISC::CLog
*log
=NLMISC::InfoLog
);
148 /// Game cycle of last config file check
149 static NLMISC::TGameCycle _LastGCChecked
;
151 /// Time of next planned shutdown sequence start
152 static TSecTime _NextPlannedShutdownStartTime
;
154 /// Time of next planned shutdown sequence end
155 static TSecTime _NextPlannedShutdownEndTime
;
159 #endif // EGS_SHUTDOWN_HANDLER_H
161 /* End of shutdown_handler.h */