mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-26 00:23:55 -07:00
server status information table
This commit is contained in:
parent
3573f74313
commit
6b0c644d2f
4 changed files with 33 additions and 5 deletions
|
|
@ -27,12 +27,16 @@
|
|||
#include "protocol.h"
|
||||
|
||||
Servatrice::Servatrice(QObject *parent)
|
||||
: Server(parent)
|
||||
: Server(parent), uptime(0)
|
||||
{
|
||||
pingClock = new QTimer(this);
|
||||
connect(pingClock, SIGNAL(timeout()), this, SIGNAL(pingClockTimeout()));
|
||||
pingClock->start(1000);
|
||||
|
||||
statusUpdateClock = new QTimer(this);
|
||||
connect(statusUpdateClock, SIGNAL(timeout()), this, SLOT(statusUpdate()));
|
||||
statusUpdateClock->start(15000);
|
||||
|
||||
ProtocolItem::initializeHash();
|
||||
settings = new QSettings("servatrice.ini", QSettings::IniFormat, this);
|
||||
|
||||
|
|
@ -179,4 +183,18 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
|
|||
return new ServerInfo_User(name, ServerInfo_User::IsUser);
|
||||
}
|
||||
|
||||
const QString Servatrice::versionString = "Servatrice 0.20101103";
|
||||
void Servatrice::statusUpdate()
|
||||
{
|
||||
uptime += statusUpdateClock->interval() / 1000;
|
||||
|
||||
checkSql();
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("insert into " + dbPrefix + "_uptime (timest, uptime, users_count, games_count) values(NOW(), :uptime, :users_count, :games_count)");
|
||||
query.bindValue(":uptime", uptime);
|
||||
query.bindValue(":users_count", users.size());
|
||||
query.bindValue(":games_count", games.size());
|
||||
execSqlQuery(query);
|
||||
}
|
||||
|
||||
const QString Servatrice::versionString = "Servatrice 0.20101116";
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class Servatrice : public Server
|
|||
Q_OBJECT
|
||||
private slots:
|
||||
void newConnection();
|
||||
void statusUpdate();
|
||||
public:
|
||||
static const QString versionString;
|
||||
Servatrice(QObject *parent = 0);
|
||||
|
|
@ -49,11 +50,12 @@ protected:
|
|||
AuthenticationResult checkUserPassword(const QString &user, const QString &password);
|
||||
ServerInfo_User *getUserData(const QString &name);
|
||||
private:
|
||||
QTimer *pingClock;
|
||||
QTimer *pingClock, *statusUpdateClock;
|
||||
QTcpServer *tcpServer;
|
||||
QString loginMessage;
|
||||
QString dbPrefix;
|
||||
QSettings *settings;
|
||||
int uptime;
|
||||
int maxGameInactivityTime;
|
||||
int maxPlayerInactivityTime;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue