mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-25 16:13:54 -07:00
Merge 4f457d9543 into 80426d77bc
This commit is contained in:
commit
ff4f92f474
4 changed files with 27 additions and 0 deletions
|
|
@ -90,6 +90,10 @@ public:
|
||||||
{
|
{
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
virtual SessionEvent *getLoginSessionEvent() const
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
virtual QString getRequiredFeatures() const
|
virtual QString getRequiredFeatures() const
|
||||||
{
|
{
|
||||||
return QString();
|
return QString();
|
||||||
|
|
|
||||||
|
|
@ -562,6 +562,11 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
|
||||||
event.set_message(server->getLoginMessage().toStdString());
|
event.set_message(server->getLoginMessage().toStdString());
|
||||||
rc.enqueuePostResponseItem(ServerMessage::SESSION_EVENT, prepareSessionEvent(event));
|
rc.enqueuePostResponseItem(ServerMessage::SESSION_EVENT, prepareSessionEvent(event));
|
||||||
|
|
||||||
|
SessionEvent *loginEvent = server->getLoginSessionEvent();
|
||||||
|
if (loginEvent) {
|
||||||
|
rc.enqueuePostResponseItem(ServerMessage::SESSION_EVENT, loginEvent);
|
||||||
|
}
|
||||||
|
|
||||||
auto *re = new Response_Login;
|
auto *re = new Response_Login;
|
||||||
re->mutable_user_info()->CopyFrom(copyUserInfo(true));
|
re->mutable_user_info()->CopyFrom(copyUserInfo(true));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -673,8 +673,22 @@ void Servatrice::statusUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SessionEvent *Servatrice::getLoginSessionEvent() const
|
||||||
|
{
|
||||||
|
// Notify newly logged-in users of a pending server shutdown
|
||||||
|
QMutexLocker locker(&shutdownStateMutex);
|
||||||
|
if (shutdownTimer && shutdownMinutes > 0) {
|
||||||
|
Event_ServerShutdown event;
|
||||||
|
event.set_reason(shutdownReason.toStdString());
|
||||||
|
event.set_minutes(static_cast<google::protobuf::uint32>(shutdownMinutes));
|
||||||
|
return Server_ProtocolHandler::prepareSessionEvent(event);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void Servatrice::scheduleShutdown(const QString &reason, int minutes)
|
void Servatrice::scheduleShutdown(const QString &reason, int minutes)
|
||||||
{
|
{
|
||||||
|
shutdownStateMutex.lock();
|
||||||
shutdownReason = reason;
|
shutdownReason = reason;
|
||||||
shutdownMinutes = minutes;
|
shutdownMinutes = minutes;
|
||||||
nextShutdownMessageMinutes = shutdownMinutes;
|
nextShutdownMessageMinutes = shutdownMinutes;
|
||||||
|
|
@ -683,6 +697,7 @@ void Servatrice::scheduleShutdown(const QString &reason, int minutes)
|
||||||
connect(shutdownTimer, SIGNAL(timeout()), this, SLOT(shutdownTimeout()));
|
connect(shutdownTimer, SIGNAL(timeout()), this, SLOT(shutdownTimeout()));
|
||||||
shutdownTimer->start(60000);
|
shutdownTimer->start(60000);
|
||||||
}
|
}
|
||||||
|
shutdownStateMutex.unlock();
|
||||||
shutdownTimeout();
|
shutdownTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -702,6 +717,7 @@ void Servatrice::incRxBytes(quint64 num)
|
||||||
|
|
||||||
void Servatrice::shutdownTimeout()
|
void Servatrice::shutdownTimeout()
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker(&shutdownStateMutex);
|
||||||
// Show every time counter cut in half & every minute for last 5 minutes
|
// Show every time counter cut in half & every minute for last 5 minutes
|
||||||
if (shutdownMinutes <= 5 || shutdownMinutes == nextShutdownMessageMinutes) {
|
if (shutdownMinutes <= 5 || shutdownMinutes == nextShutdownMessageMinutes) {
|
||||||
if (shutdownMinutes == nextShutdownMessageMinutes) {
|
if (shutdownMinutes == nextShutdownMessageMinutes) {
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,7 @@ private:
|
||||||
Servatrice_IslServer *islServer;
|
Servatrice_IslServer *islServer;
|
||||||
mutable QMutex loginMessageMutex;
|
mutable QMutex loginMessageMutex;
|
||||||
QString loginMessage;
|
QString loginMessage;
|
||||||
|
mutable QMutex shutdownStateMutex;
|
||||||
QString dbPrefix;
|
QString dbPrefix;
|
||||||
QMap<QString, bool> serverRequiredFeatureList;
|
QMap<QString, bool> serverRequiredFeatureList;
|
||||||
QString officialWarnings;
|
QString officialWarnings;
|
||||||
|
|
@ -216,6 +217,7 @@ public:
|
||||||
QMutexLocker locker(&loginMessageMutex);
|
QMutexLocker locker(&loginMessageMutex);
|
||||||
return loginMessage;
|
return loginMessage;
|
||||||
}
|
}
|
||||||
|
SessionEvent *getLoginSessionEvent() const override;
|
||||||
QString getRequiredFeatures() const override;
|
QString getRequiredFeatures() const override;
|
||||||
QString getAuthenticationMethodString() const;
|
QString getAuthenticationMethodString() const;
|
||||||
QString getDBTypeString() const;
|
QString getDBTypeString() const;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue