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
eb583360
Commit
eb583360
authored
Aug 11, 2015
by
woogerboy21
Browse files
Add clientid field to sessions table.
parent
de1b925b
Changes
6
Hide whitespace changes
Inline
Side-by-side
common/server.cpp
View file @
eb583360
...
@@ -150,7 +150,7 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
...
@@ -150,7 +150,7 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
users
.
insert
(
name
,
session
);
users
.
insert
(
name
,
session
);
qDebug
()
<<
"Server::loginUser:"
<<
session
<<
"name="
<<
name
;
qDebug
()
<<
"Server::loginUser:"
<<
session
<<
"name="
<<
name
;
data
.
set_session_id
(
databaseInterface
->
startSession
(
name
,
session
->
getAddress
()));
data
.
set_session_id
(
databaseInterface
->
startSession
(
name
,
session
->
getAddress
()
,
clientid
));
databaseInterface
->
unlockSessionTables
();
databaseInterface
->
unlockSessionTables
();
usersBySessionId
.
insert
(
data
.
session_id
(),
session
);
usersBySessionId
.
insert
(
data
.
session_id
(),
session
);
...
...
common/server_database_interface.h
View file @
eb583360
...
@@ -24,7 +24,7 @@ public:
...
@@ -24,7 +24,7 @@ public:
virtual
void
storeGameInformation
(
const
QString
&
/* roomName */
,
const
QStringList
&
/* roomGameTypes */
,
const
ServerInfo_Game
&
/* gameInfo */
,
const
QSet
<
QString
>
&
/* allPlayersEver */
,
const
QSet
<
QString
>
&
/* allSpectatorsEver */
,
const
QList
<
GameReplay
*>
&
/* replayList */
)
{
}
virtual
void
storeGameInformation
(
const
QString
&
/* roomName */
,
const
QStringList
&
/* roomGameTypes */
,
const
ServerInfo_Game
&
/* gameInfo */
,
const
QSet
<
QString
>
&
/* allPlayersEver */
,
const
QSet
<
QString
>
&
/* allSpectatorsEver */
,
const
QList
<
GameReplay
*>
&
/* replayList */
)
{
}
virtual
DeckList
*
getDeckFromDatabase
(
int
/* deckId */
,
int
/* userId */
)
{
return
0
;
}
virtual
DeckList
*
getDeckFromDatabase
(
int
/* deckId */
,
int
/* userId */
)
{
return
0
;
}
virtual
qint64
startSession
(
const
QString
&
/* userName */
,
const
QString
&
/* address */
)
{
return
0
;
}
virtual
qint64
startSession
(
const
QString
&
/* userName */
,
const
QString
&
/* address
*/
,
const
QString
&
/* clientId
*/
)
{
return
0
;
}
virtual
bool
usernameIsValid
(
const
QString
&
/*userName */
,
QString
&
/* error */
)
{
return
true
;
};
virtual
bool
usernameIsValid
(
const
QString
&
/*userName */
,
QString
&
/* error */
)
{
return
true
;
};
public
slots
:
public
slots
:
virtual
void
endSession
(
qint64
/* sessionId */
)
{
}
virtual
void
endSession
(
qint64
/* sessionId */
)
{
}
...
...
servatrice/migrations/servatrice_0003_to_0004.sql
0 → 100644
View file @
eb583360
-- Servatrice db migration from version 3 to version 4
alter
table
cockatrice_sessions
add
clientid
varchar
(
15
)
not
null
;
UPDATE
cockatrice_schema_version
SET
version
=
4
WHERE
version
=
3
;
servatrice/servatrice.sql
View file @
eb583360
...
@@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_schema_version` (
...
@@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `cockatrice_schema_version` (
PRIMARY
KEY
(
`version`
)
PRIMARY
KEY
(
`version`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
;
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
utf8
;
INSERT
INTO
cockatrice_schema_version
VALUES
(
3
);
INSERT
INTO
cockatrice_schema_version
VALUES
(
4
);
CREATE
TABLE
IF
NOT
EXISTS
`cockatrice_decklist_files`
(
CREATE
TABLE
IF
NOT
EXISTS
`cockatrice_decklist_files`
(
`id`
int
(
7
)
unsigned
zerofill
NOT
NULL
auto_increment
,
`id`
int
(
7
)
unsigned
zerofill
NOT
NULL
auto_increment
,
...
...
servatrice/src/servatrice_database_interface.cpp
View file @
eb583360
...
@@ -536,7 +536,7 @@ bool Servatrice_DatabaseInterface::userSessionExists(const QString &userName)
...
@@ -536,7 +536,7 @@ bool Servatrice_DatabaseInterface::userSessionExists(const QString &userName)
return
query
->
next
();
return
query
->
next
();
}
}
qint64
Servatrice_DatabaseInterface
::
startSession
(
const
QString
&
userName
,
const
QString
&
address
)
qint64
Servatrice_DatabaseInterface
::
startSession
(
const
QString
&
userName
,
const
QString
&
address
,
const
QString
&
clientId
)
{
{
if
(
server
->
getAuthenticationMethod
()
==
Servatrice
::
AuthenticationNone
)
if
(
server
->
getAuthenticationMethod
()
==
Servatrice
::
AuthenticationNone
)
return
-
1
;
return
-
1
;
...
@@ -544,10 +544,11 @@ qint64 Servatrice_DatabaseInterface::startSession(const QString &userName, const
...
@@ -544,10 +544,11 @@ qint64 Servatrice_DatabaseInterface::startSession(const QString &userName, const
if
(
!
checkSql
())
if
(
!
checkSql
())
return
-
1
;
return
-
1
;
QSqlQuery
*
query
=
prepareQuery
(
"insert into {prefix}_sessions (user_name, id_server, ip_address, start_time) values(:user_name, :id_server, :ip_address, NOW())"
);
QSqlQuery
*
query
=
prepareQuery
(
"insert into {prefix}_sessions (user_name, id_server, ip_address, start_time
, clientid
) values(:user_name, :id_server, :ip_address, NOW()
, :client_id
)"
);
query
->
bindValue
(
":user_name"
,
userName
);
query
->
bindValue
(
":user_name"
,
userName
);
query
->
bindValue
(
":id_server"
,
server
->
getServerId
());
query
->
bindValue
(
":id_server"
,
server
->
getServerId
());
query
->
bindValue
(
":ip_address"
,
address
);
query
->
bindValue
(
":ip_address"
,
address
);
query
->
bindValue
(
":client_id"
,
clientId
);
if
(
execSqlQuery
(
query
))
if
(
execSqlQuery
(
query
))
return
query
->
lastInsertId
().
toInt
();
return
query
->
lastInsertId
().
toInt
();
return
-
1
;
return
-
1
;
...
...
servatrice/src/servatrice_database_interface.h
View file @
eb583360
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include
"server.h"
#include
"server.h"
#include
"server_database_interface.h"
#include
"server_database_interface.h"
#define DATABASE_SCHEMA_VERSION
3
#define DATABASE_SCHEMA_VERSION
4
class
Servatrice
;
class
Servatrice
;
...
@@ -59,7 +59,7 @@ public:
...
@@ -59,7 +59,7 @@ public:
int
getNextGameId
();
int
getNextGameId
();
int
getNextReplayId
();
int
getNextReplayId
();
int
getActiveUserCount
();
int
getActiveUserCount
();
qint64
startSession
(
const
QString
&
userName
,
const
QString
&
address
);
qint64
startSession
(
const
QString
&
userName
,
const
QString
&
address
,
const
QString
&
clientId
);
void
endSession
(
qint64
sessionId
);
void
endSession
(
qint64
sessionId
);
void
clearSessionTables
();
void
clearSessionTables
();
void
lockSessionTables
();
void
lockSessionTables
();
...
...
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