mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Updated server shutdown timer logic
Will follow the following rules + send a message initially + send a message every 20 mins + send a message every min when time <= 5 Updated client popup Updated client to close any previous popups and bring up a new one. NEEDS TO BE TESTED added missing include Added delete on close
This commit is contained in:
parent
82d8c72427
commit
e646122f55
4 changed files with 34 additions and 21 deletions
|
|
@ -126,7 +126,7 @@ void Servatrice_IslServer::incomingConnection(qintptr socketDescriptor)
|
|||
}
|
||||
|
||||
Servatrice::Servatrice(QObject *parent)
|
||||
: Server(true, parent), uptime(0), shutdownTimer(0)
|
||||
: Server(true, parent), uptime(0), shutdownTimer(0), isFirstShutdownMessage(true)
|
||||
{
|
||||
qRegisterMetaType<QSqlDatabase>("QSqlDatabase");
|
||||
}
|
||||
|
|
@ -485,26 +485,29 @@ void Servatrice::shutdownTimeout()
|
|||
{
|
||||
--shutdownMinutes;
|
||||
|
||||
SessionEvent *se;
|
||||
if (shutdownMinutes) {
|
||||
Event_ServerShutdown event;
|
||||
event.set_reason(shutdownReason.toStdString());
|
||||
event.set_minutes(shutdownMinutes);
|
||||
se = Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
} else {
|
||||
Event_ConnectionClosed event;
|
||||
event.set_reason(Event_ConnectionClosed::SERVER_SHUTDOWN);
|
||||
se = Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
if (shutdownMinutes <= 5 || isFirstShutdownMessage || shutdownMinutes % 20 == 0) {
|
||||
isFirstShutdownMessage = false;
|
||||
SessionEvent *se;
|
||||
if (shutdownMinutes) {
|
||||
Event_ServerShutdown event;
|
||||
event.set_reason(shutdownReason.toStdString());
|
||||
event.set_minutes(shutdownMinutes);
|
||||
se = Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
} else {
|
||||
Event_ConnectionClosed event;
|
||||
event.set_reason(Event_ConnectionClosed::SERVER_SHUTDOWN);
|
||||
se = Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
}
|
||||
|
||||
clientsLock.lockForRead();
|
||||
for (int i = 0; i < clients.size(); ++i)
|
||||
clients[i]->sendProtocolItem(*se);
|
||||
clientsLock.unlock();
|
||||
delete se;
|
||||
|
||||
if (!shutdownMinutes)
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
clientsLock.lockForRead();
|
||||
for (int i = 0; i < clients.size(); ++i)
|
||||
clients[i]->sendProtocolItem(*se);
|
||||
clientsLock.unlock();
|
||||
delete se;
|
||||
|
||||
if (!shutdownMinutes)
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
bool Servatrice::islConnectionExists(int serverId) const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue