Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
6b0c644d
Commit
6b0c644d
authored
Nov 16, 2010
by
Max-Wilhelm Bruker
Browse files
server status information table
parent
3573f743
Changes
4
Hide whitespace changes
Inline
Side-by-side
common/server.h
View file @
6b0c644d
...
@@ -38,12 +38,12 @@ public:
...
@@ -38,12 +38,12 @@ public:
virtual
bool
getGameShouldPing
()
const
=
0
;
virtual
bool
getGameShouldPing
()
const
=
0
;
virtual
int
getMaxGameInactivityTime
()
const
=
0
;
virtual
int
getMaxGameInactivityTime
()
const
=
0
;
virtual
int
getMaxPlayerInactivityTime
()
const
=
0
;
virtual
int
getMaxPlayerInactivityTime
()
const
=
0
;
pr
ivate
:
pr
otected
:
QMap
<
int
,
Server_Game
*>
games
;
QMap
<
int
,
Server_Game
*>
games
;
QList
<
Server_ProtocolHandler
*>
clients
;
QList
<
Server_ProtocolHandler
*>
clients
;
QMap
<
QString
,
Server_ProtocolHandler
*>
users
;
QMap
<
QString
,
Server_ProtocolHandler
*>
users
;
QMap
<
QString
,
Server_ChatChannel
*>
chatChannels
;
QMap
<
QString
,
Server_ChatChannel
*>
chatChannels
;
protected:
virtual
AuthenticationResult
checkUserPassword
(
const
QString
&
user
,
const
QString
&
password
)
=
0
;
virtual
AuthenticationResult
checkUserPassword
(
const
QString
&
user
,
const
QString
&
password
)
=
0
;
virtual
ServerInfo_User
*
getUserData
(
const
QString
&
name
)
=
0
;
virtual
ServerInfo_User
*
getUserData
(
const
QString
&
name
)
=
0
;
int
nextGameId
;
int
nextGameId
;
...
...
servatrice/servatrice.sql
View file @
6b0c644d
...
@@ -111,3 +111,11 @@ CREATE TABLE IF NOT EXISTS `users` (
...
@@ -111,3 +111,11 @@ CREATE TABLE IF NOT EXISTS `users` (
`token`
char
(
32
)
NOT
NULL
,
`token`
char
(
32
)
NOT
NULL
,
PRIMARY
KEY
(
`id`
)
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
latin1
AUTO_INCREMENT
=
915
;
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
latin1
AUTO_INCREMENT
=
915
;
CREATE
TABLE
`cockatrice_uptime`
(
`timest`
datetime
NOT
NULL
DEFAULT
'0000-00-00 00:00:00'
,
`uptime`
int
(
11
)
DEFAULT
NULL
,
`users_count`
int
(
11
)
DEFAULT
NULL
,
`games_count`
int
(
11
)
DEFAULT
NULL
,
PRIMARY
KEY
(
`timest`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
;
servatrice/src/servatrice.cpp
View file @
6b0c644d
...
@@ -27,12 +27,16 @@
...
@@ -27,12 +27,16 @@
#include
"protocol.h"
#include
"protocol.h"
Servatrice
::
Servatrice
(
QObject
*
parent
)
Servatrice
::
Servatrice
(
QObject
*
parent
)
:
Server
(
parent
)
:
Server
(
parent
)
,
uptime
(
0
)
{
{
pingClock
=
new
QTimer
(
this
);
pingClock
=
new
QTimer
(
this
);
connect
(
pingClock
,
SIGNAL
(
timeout
()),
this
,
SIGNAL
(
pingClockTimeout
()));
connect
(
pingClock
,
SIGNAL
(
timeout
()),
this
,
SIGNAL
(
pingClockTimeout
()));
pingClock
->
start
(
1000
);
pingClock
->
start
(
1000
);
statusUpdateClock
=
new
QTimer
(
this
);
connect
(
statusUpdateClock
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
statusUpdate
()));
statusUpdateClock
->
start
(
15000
);
ProtocolItem
::
initializeHash
();
ProtocolItem
::
initializeHash
();
settings
=
new
QSettings
(
"servatrice.ini"
,
QSettings
::
IniFormat
,
this
);
settings
=
new
QSettings
(
"servatrice.ini"
,
QSettings
::
IniFormat
,
this
);
...
@@ -179,4 +183,18 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
...
@@ -179,4 +183,18 @@ ServerInfo_User *Servatrice::getUserData(const QString &name)
return
new
ServerInfo_User
(
name
,
ServerInfo_User
::
IsUser
);
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"
;
servatrice/src/servatrice.h
View file @
6b0c644d
...
@@ -33,6 +33,7 @@ class Servatrice : public Server
...
@@ -33,6 +33,7 @@ class Servatrice : public Server
Q_OBJECT
Q_OBJECT
private
slots
:
private
slots
:
void
newConnection
();
void
newConnection
();
void
statusUpdate
();
public:
public:
static
const
QString
versionString
;
static
const
QString
versionString
;
Servatrice
(
QObject
*
parent
=
0
);
Servatrice
(
QObject
*
parent
=
0
);
...
@@ -49,11 +50,12 @@ protected:
...
@@ -49,11 +50,12 @@ protected:
AuthenticationResult
checkUserPassword
(
const
QString
&
user
,
const
QString
&
password
);
AuthenticationResult
checkUserPassword
(
const
QString
&
user
,
const
QString
&
password
);
ServerInfo_User
*
getUserData
(
const
QString
&
name
);
ServerInfo_User
*
getUserData
(
const
QString
&
name
);
private:
private:
QTimer
*
pingClock
;
QTimer
*
pingClock
,
*
statusUpdateClock
;
QTcpServer
*
tcpServer
;
QTcpServer
*
tcpServer
;
QString
loginMessage
;
QString
loginMessage
;
QString
dbPrefix
;
QString
dbPrefix
;
QSettings
*
settings
;
QSettings
*
settings
;
int
uptime
;
int
maxGameInactivityTime
;
int
maxGameInactivityTime
;
int
maxPlayerInactivityTime
;
int
maxPlayerInactivityTime
;
};
};
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment