mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[Servatrice] Notify newly logged-in users of pending server shutdown (#6976)
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
This commit is contained in:
parent
83fd65b34b
commit
83920a4ae9
4 changed files with 34 additions and 4 deletions
|
|
@ -91,6 +91,10 @@ public:
|
|||
{
|
||||
return QString();
|
||||
}
|
||||
virtual SessionEvent *getLoginSessionEvent() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
virtual QString getRequiredFeatures() const
|
||||
{
|
||||
return QString();
|
||||
|
|
|
|||
|
|
@ -562,6 +562,11 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
|||
event.set_message(server->getLoginMessage().toStdString());
|
||||
rc.enqueuePostResponseItem(ServerMessage::SESSION_EVENT, prepareSessionEvent(event));
|
||||
|
||||
SessionEvent *loginEvent = server->getLoginSessionEvent();
|
||||
if (loginEvent) {
|
||||
rc.enqueuePostResponseItem(ServerMessage::SESSION_EVENT, loginEvent);
|
||||
}
|
||||
|
||||
auto *re = new Response_Login;
|
||||
re->mutable_user_info()->CopyFrom(copyUserInfo(true));
|
||||
|
||||
|
|
|
|||
|
|
@ -673,8 +673,27 @@ void Servatrice::statusUpdate()
|
|||
}
|
||||
}
|
||||
|
||||
SessionEvent *Servatrice::makeShutdownEvent() const
|
||||
{
|
||||
Event_ServerShutdown event;
|
||||
event.set_reason(shutdownReason.toStdString());
|
||||
event.set_minutes(static_cast<google::protobuf::uint32>(shutdownMinutes));
|
||||
return Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
}
|
||||
|
||||
SessionEvent *Servatrice::getLoginSessionEvent() const
|
||||
{
|
||||
// Notify newly logged-in users of a pending server shutdown
|
||||
QMutexLocker locker(&shutdownStateMutex);
|
||||
if (shutdownTimer && shutdownMinutes > 0) {
|
||||
return makeShutdownEvent();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Servatrice::scheduleShutdown(const QString &reason, int minutes)
|
||||
{
|
||||
shutdownStateMutex.lock();
|
||||
shutdownReason = reason;
|
||||
shutdownMinutes = minutes;
|
||||
nextShutdownMessageMinutes = shutdownMinutes;
|
||||
|
|
@ -683,6 +702,7 @@ void Servatrice::scheduleShutdown(const QString &reason, int minutes)
|
|||
connect(shutdownTimer, SIGNAL(timeout()), this, SLOT(shutdownTimeout()));
|
||||
shutdownTimer->start(60000);
|
||||
}
|
||||
shutdownStateMutex.unlock();
|
||||
shutdownTimeout();
|
||||
}
|
||||
|
||||
|
|
@ -702,6 +722,7 @@ void Servatrice::incRxBytes(quint64 num)
|
|||
|
||||
void Servatrice::shutdownTimeout()
|
||||
{
|
||||
QMutexLocker locker(&shutdownStateMutex);
|
||||
// Show every time counter cut in half & every minute for last 5 minutes
|
||||
if (shutdownMinutes <= 5 || shutdownMinutes == nextShutdownMessageMinutes) {
|
||||
if (shutdownMinutes == nextShutdownMessageMinutes) {
|
||||
|
|
@ -710,10 +731,7 @@ void Servatrice::shutdownTimeout()
|
|||
|
||||
SessionEvent *se;
|
||||
if (shutdownMinutes) {
|
||||
Event_ServerShutdown event;
|
||||
event.set_reason(shutdownReason.toStdString());
|
||||
event.set_minutes(static_cast<google::protobuf::uint32>(shutdownMinutes));
|
||||
se = Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
se = makeShutdownEvent();
|
||||
} else {
|
||||
Event_ConnectionClosed event;
|
||||
event.set_reason(Event_ConnectionClosed::SERVER_SHUTDOWN);
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ private:
|
|||
Servatrice_IslServer *islServer;
|
||||
mutable QMutex loginMessageMutex;
|
||||
QString loginMessage;
|
||||
mutable QMutex shutdownStateMutex;
|
||||
QString dbPrefix;
|
||||
QMap<QString, bool> serverRequiredFeatureList;
|
||||
QString officialWarnings;
|
||||
|
|
@ -216,6 +217,8 @@ public:
|
|||
QMutexLocker locker(&loginMessageMutex);
|
||||
return loginMessage;
|
||||
}
|
||||
SessionEvent *getLoginSessionEvent() const override;
|
||||
SessionEvent *makeShutdownEvent() const;
|
||||
QString getRequiredFeatures() const override;
|
||||
QString getAuthenticationMethodString() const;
|
||||
QString getDBTypeString() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue