mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 03:53:26 -08:00
[Server] Serve the login message through the database interface (#7854)
This commit is contained in:
parent
ec3ad812f0
commit
f8f8fffa6b
4 changed files with 35 additions and 18 deletions
|
|
@ -820,26 +820,20 @@ void Servatrice::updateLoginMessage()
|
|||
return;
|
||||
}
|
||||
|
||||
QSqlQuery *query = servatriceDatabaseInterface->prepareQuery(
|
||||
"select message from {prefix}_servermessages where id_server = :id_server order by timest desc limit 1");
|
||||
query->bindValue(":id_server", serverId);
|
||||
if (servatriceDatabaseInterface->execSqlQuery(query)) {
|
||||
if (query->next()) {
|
||||
const QString newLoginMessage = query->value(0).toString();
|
||||
QString newLoginMessage;
|
||||
if (servatriceDatabaseInterface->getLatestServerMessage(serverId, newLoginMessage)) {
|
||||
loginMessageMutex.lock();
|
||||
loginMessage = newLoginMessage;
|
||||
loginMessageMutex.unlock();
|
||||
|
||||
loginMessageMutex.lock();
|
||||
loginMessage = newLoginMessage;
|
||||
loginMessageMutex.unlock();
|
||||
|
||||
Event_ServerMessage event;
|
||||
event.set_message(newLoginMessage.toStdString());
|
||||
SessionEvent *se = Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
QMapIterator<QString, Server_ProtocolHandler *> usersIterator(users);
|
||||
while (usersIterator.hasNext()) {
|
||||
usersIterator.next().value()->sendProtocolItem(*se);
|
||||
}
|
||||
delete se;
|
||||
Event_ServerMessage event;
|
||||
event.set_message(newLoginMessage.toStdString());
|
||||
SessionEvent *se = Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
QMapIterator<QString, Server_ProtocolHandler *> usersIterator(users);
|
||||
while (usersIterator.hasNext()) {
|
||||
usersIterator.next().value()->sendProtocolItem(*se);
|
||||
}
|
||||
delete se;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue