mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-27 21:23:28 -08:00
Remedy connection type query at every login (#2298)
Fix #2285 This change adds an internal counter for each tcp/web socket connection that the server makes and queries the stored memory count at login rather than the previous way that quired the database during each login. Each login that quired the DB put a significant load on the server as the user base grew.
This commit is contained in:
@@ -38,7 +38,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
Server::Server(QObject *parent)
|
||||
: QObject(parent), nextLocalGameId(0)
|
||||
: QObject(parent), nextLocalGameId(0), tcpUserCount(0), webSocketUserCount(0)
|
||||
{
|
||||
qRegisterMetaType<ServerInfo_Ban>("ServerInfo_Ban");
|
||||
qRegisterMetaType<ServerInfo_Game>("ServerInfo_Game");
|
||||
@@ -202,12 +202,25 @@ Server_AbstractUserInterface *Server::findUser(const QString &userName) const
|
||||
|
||||
void Server::addClient(Server_ProtocolHandler *client)
|
||||
{
|
||||
if (client->getConnectionType() == "tcp")
|
||||
tcpUserCount++;
|
||||
|
||||
if (client->getConnectionType() == "websocket")
|
||||
webSocketUserCount++;
|
||||
|
||||
QWriteLocker locker(&clientsLock);
|
||||
clients << client;
|
||||
}
|
||||
|
||||
void Server::removeClient(Server_ProtocolHandler *client)
|
||||
{
|
||||
|
||||
if (client->getConnectionType() == "tcp")
|
||||
tcpUserCount--;
|
||||
|
||||
if (client->getConnectionType() == "websocket")
|
||||
webSocketUserCount--;
|
||||
|
||||
QWriteLocker locker(&clientsLock);
|
||||
clients.removeAt(clients.indexOf(client));
|
||||
ServerInfo_User *data = client->getUserInfo();
|
||||
|
||||
Reference in New Issue
Block a user