mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-06-17 14:12:25 +00:00
TNetwork: kick everyone before shutdown
in the future this can be used to show a message to the clients that the server is shutting down
This commit is contained in:
@@ -9,6 +9,15 @@ TNetwork::TNetwork(TServer& Server, TPPSMonitor& PPSMonitor, TResourceManager& R
|
|||||||
: mServer(Server)
|
: mServer(Server)
|
||||||
, mPPSMonitor(PPSMonitor)
|
, mPPSMonitor(PPSMonitor)
|
||||||
, mResourceManager(ResourceManager) {
|
, mResourceManager(ResourceManager) {
|
||||||
|
Application::RegisterShutdownHandler([&] {
|
||||||
|
debug("Kicking all players due to shutdown");
|
||||||
|
Server.ForEachClient([&](std::weak_ptr<TClient> client) -> bool {
|
||||||
|
if (!client.expired()) {
|
||||||
|
ClientKick(*client.lock(), "Server shutdown");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
Application::RegisterShutdownHandler([&] {
|
Application::RegisterShutdownHandler([&] {
|
||||||
if (mUDPThread.joinable()) {
|
if (mUDPThread.joinable()) {
|
||||||
debug("shutting down TCPServer");
|
debug("shutting down TCPServer");
|
||||||
|
|||||||
Reference in New Issue
Block a user