Merge branch 'stable' into serverstuff_stable
This commit is contained in:
@@ -15,7 +15,7 @@ Linux:
|
||||
- libSDL_mixer, libSDL --> http://www.libsdl.org/
|
||||
- libSQLite3 --> http://sqlite.org/
|
||||
- libtinyxml > 2.0 --> http://www.sourceforge.net/projects/tinyxml
|
||||
- protoc >= 2.3.0 (during build), libprotobuf >= 2.3.0 -> http://code.google.com/p/protobuf/downloads/list
|
||||
- protoc >= 2.3.0 (during build), libprotobuf >= 2.3.0 -> https://github.com/google/protobuf
|
||||
- For the server: libircclient 1.3 --> http://www.sourceforge.net/projects/libircclient/
|
||||
|
||||
Windows:
|
||||
@@ -28,7 +28,7 @@ Basic Installation
|
||||
Linux:
|
||||
|
||||
1. Type "cd path/to/the/sources". Then do for example "/usr/qt/4/bin/qmake pokerth.pro" to configure the makefile for your system.
|
||||
Pay attention that the QTDIR environment varialbe points to Qt4 not Qt3. For example QTDIR=/usr/qt/4.
|
||||
Pay attention that the QTDIR environment variable points to Qt4 not Qt3. For example QTDIR=/usr/qt/4.
|
||||
You can set this variable typing: "export QTDIR=/usr/qt/4"
|
||||
|
||||
2. Type "make" to compile the package.
|
||||
|
||||
+11
-2
@@ -1,8 +1,17 @@
|
||||
# QMake pro-file for PokerTH
|
||||
|
||||
TEMPLATE = subdirs
|
||||
SUBDIRS = pokerth_protocol.pro pokerth_db.pro pokerth_lib.pro pokerth_game.pro
|
||||
!mac:!gui_800x480:!client {
|
||||
SUBDIRS = pokerth_protocol.pro pokerth_db.pro pokerth_lib.pro
|
||||
official_server {
|
||||
SUBDIRS += pokerth_dbofficial.pro
|
||||
}
|
||||
qml-client{
|
||||
SUBDIRS += pokerth_qml-client.pro
|
||||
}
|
||||
!qml-client{
|
||||
SUBDIRS += pokerth_game.pro
|
||||
}
|
||||
!mac:!gui_800x480:!client:!qml-client {
|
||||
SUBDIRS += pokerth_server.pro chatcleaner.pro
|
||||
}
|
||||
CONFIG += ordered
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
# QMake pro-file for PokerTH official server DB backend
|
||||
TEMPLATE = lib
|
||||
CODECFORSRC = UTF-8
|
||||
CONFIG += staticlib \
|
||||
thread \
|
||||
exceptions \
|
||||
rtti \
|
||||
stl \
|
||||
warn_on
|
||||
UI_DIR = uics
|
||||
TARGET = lib/pokerth_dbofficial
|
||||
MOC_DIR = mocs
|
||||
OBJECTS_DIR = obj
|
||||
QT -= core \
|
||||
gui
|
||||
|
||||
# PRECOMPILED_HEADER = dbofficial/pch_lib.h
|
||||
INCLUDEPATH += . \
|
||||
./src
|
||||
DEPENDPATH += . \
|
||||
./src
|
||||
|
||||
# Input
|
||||
HEADERS += src/dbofficial/asyncdbauth.h \
|
||||
src/dbofficial/asyncdbcreategame.h \
|
||||
src/dbofficial/asyncdbgameplace.h \
|
||||
src/dbofficial/asyncdbupdatescore.h \
|
||||
src/dbofficial/asyncdbquery.h \
|
||||
src/dbofficial/serverdbthread.h \
|
||||
src/dbofficial/serverdbfactoryinternal.h \
|
||||
src/dbofficial/compositeasyncdbquery.h \
|
||||
src/dbofficial/singleasyncdbquery.h \
|
||||
src/dbofficial/querycontext.h \
|
||||
src/dbofficial/asyncdbendgame.h \
|
||||
src/dbofficial/db_table_defs.h \
|
||||
src/dbofficial/asyncdblogin.h \
|
||||
src/dbofficial/asyncdbreportavatar.h \
|
||||
src/dbofficial/asyncdbreportgame.h \
|
||||
src/dbofficial/asyncdbavatarblacklist.h \
|
||||
src/dbofficial/asyncdbadminplayers.h \
|
||||
src/dbofficial/asyncdbblockplayer.h \
|
||||
src/dbofficial/dbidmanager.h
|
||||
SOURCES += src/dbofficial/asyncdbauth.cpp \
|
||||
src/dbofficial/asyncdbcreategame.cpp \
|
||||
src/dbofficial/asyncdbgameplace.cpp \
|
||||
src/dbofficial/asyncdbupdatescore.cpp \
|
||||
src/dbofficial/asyncdbquery.cpp \
|
||||
src/dbofficial/serverdbthread.cpp \
|
||||
src/dbofficial/serverdbfactoryinternal.cpp \
|
||||
src/dbofficial/singleasyncdbquery.cpp \
|
||||
src/dbofficial/compositeasyncdbquery.cpp \
|
||||
src/dbofficial/querycontext.cpp \
|
||||
src/dbofficial/asyncdbendgame.cpp \
|
||||
src/dbofficial/asyncdblogin.cpp \
|
||||
src/dbofficial/asyncdbreportavatar.cpp \
|
||||
src/dbofficial/asyncdbreportgame.cpp \
|
||||
src/dbofficial/asyncdbavatarblacklist.cpp \
|
||||
src/dbofficial/asyncdbadminplayers.cpp \
|
||||
src/dbofficial/asyncdbblockplayer.cpp \
|
||||
src/dbofficial/dbidmanager.cpp
|
||||
win32 {
|
||||
DEFINES += _WIN32_WINNT=0x0501
|
||||
INCLUDEPATH += ../../../boost/ \
|
||||
../../../GnuTLS/include \
|
||||
../../../curl/include \
|
||||
../../../mysql/include \
|
||||
../../../mysql++/lib \
|
||||
../../../zlib
|
||||
}
|
||||
!win32 {
|
||||
# #### My release static build options
|
||||
# QMAKE_CXXFLAGS += -ffunction-sections -fdata-sections
|
||||
INCLUDEPATH += /usr/include \
|
||||
/usr/include/mysql \
|
||||
/usr/include/mysql++
|
||||
INCLUDEPATH += /opt/boost/include
|
||||
}
|
||||
mac {
|
||||
# make it universal
|
||||
CONFIG += x86
|
||||
CONFIG -= ppc
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
|
||||
|
||||
# for universal-compilation on PPC-Mac uncomment the following line
|
||||
# on Intel-Mac you have to comment this line out or build will fail.
|
||||
# QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk/
|
||||
INCLUDEPATH += /Developer/SDKs/MacOSX10.5.sdk/usr/include/
|
||||
INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers
|
||||
INCLUDEPATH += /Library/Frameworks/SDL_mixer.framework/Headers
|
||||
INCLUDEPATH += /opt/local/include/mysql++ \
|
||||
/opt/local/include/mysql5/mysql
|
||||
}
|
||||
+1
-1
@@ -601,7 +601,7 @@ mac {
|
||||
OTHER_FILES += docs/infomessage-id-desc.txt
|
||||
official_server {
|
||||
LIBPATH += pkth_stat/daemon_lib/lib
|
||||
LIBS += -lpokerth_closed \
|
||||
LIBS += -lpokerth_dbofficial \
|
||||
-lmysqlpp
|
||||
DEFINES += POKERTH_OFFICIAL_SERVER
|
||||
}
|
||||
|
||||
+1
-1
@@ -322,7 +322,7 @@ mac {
|
||||
|
||||
official_server {
|
||||
LIBPATH += pkth_stat/daemon_lib/lib
|
||||
LIBS += -lpokerth_closed -lmysqlpp
|
||||
LIBS += -lpokerth_dbofficial -lmysqlpp
|
||||
DEFINES += POKERTH_OFFICIAL_SERVER
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/asyncdbadminplayers.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBAdminPlayers::AsyncDBAdminPlayers(unsigned queryId, const string &preparedName)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, list<string>())
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBAdminPlayers::~AsyncDBAdminPlayers()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAdminPlayers::Init(DBIdManager& /*idManager*/)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAdminPlayers::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
list<DB_id> adminPlayers;
|
||||
for (size_t i = 0; i < result.num_rows(); ++i) {
|
||||
if (!result[i].empty()) {
|
||||
adminPlayers.push_back(result[i][0]);
|
||||
}
|
||||
}
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerAdminList, &cb, GetId(), adminPlayers));
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAdminPlayers::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query should always produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAdminPlayers::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::QueryError, &cb, "AsyncDBAdminPlayers: Failure."));
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database query for all admin players. */
|
||||
|
||||
#ifndef _ASYNCDBADMINPLAYERS_H_
|
||||
#define _ASYNCDBADMINPLAYERS_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBAdminPlayers : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBAdminPlayers(unsigned queryId, const std::string &preparedName);
|
||||
virtual ~AsyncDBAdminPlayers();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbauth.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBAuth::AsyncDBAuth(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBAuth::~AsyncDBAuth()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAuth::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
if (result.num_rows() != 1) {
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &cb, GetId()));
|
||||
} else {
|
||||
int valid = result[0][2];
|
||||
int active = result[0][5];
|
||||
if ((valid != 1) || (active != 1)) {
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginBlocked, &cb, GetId()));
|
||||
} else {
|
||||
mysqlpp::String secret(result[0][1]);
|
||||
mysqlpp::String country(result[0][3]);
|
||||
mysqlpp::String last_login(result[0][4]);
|
||||
boost::shared_ptr<DBPlayerData> tmpData(new DBPlayerData);
|
||||
tmpData->id = result[0][0];
|
||||
secret.to_string(tmpData->secret);
|
||||
if (!country.is_null())
|
||||
country.to_string(tmpData->country);
|
||||
last_login.to_string(tmpData->last_login);
|
||||
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginSuccess, &cb, GetId(), tmpData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAuth::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAuth::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &cb, GetId()));
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database auth query. */
|
||||
|
||||
#ifndef _ASYNCDBAUTH_H_
|
||||
#define _ASYNCDBAUTH_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBAuth : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBAuth(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBAuth();
|
||||
|
||||
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,68 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbavatarblacklist.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBAvatarBlacklist::AsyncDBAvatarBlacklist(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBAvatarBlacklist::~AsyncDBAvatarBlacklist()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAvatarBlacklist::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
if (result.num_rows() == 0)
|
||||
service.post(boost::bind(&ServerDBCallback::AvatarIsOK, &cb, GetId()));
|
||||
else
|
||||
service.post(boost::bind(&ServerDBCallback::AvatarIsBlacklisted, &cb, GetId()));
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAvatarBlacklist::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBAvatarBlacklist::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// If query failed: Avatar is blacklisted.
|
||||
service.post(boost::bind(&ServerDBCallback::AvatarIsBlacklisted, &cb, GetId()));
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database avatar blacklist query. */
|
||||
|
||||
#ifndef _ASYNCDBAVATARBLACKLIST_H_
|
||||
#define _ASYNCDBAVATARBLACKLIST_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBAvatarBlacklist : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBAvatarBlacklist(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBAvatarBlacklist();
|
||||
|
||||
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,71 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbblockplayer.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBBlockPlayer::AsyncDBBlockPlayer(unsigned queryId, unsigned replyId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params), m_replyId(replyId)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBBlockPlayer::~AsyncDBBlockPlayer()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBBlockPlayer::Init(DBIdManager &/*idManager*/)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBBlockPlayer::HandleResult(mysqlpp::Query &/*query*/, DBIdManager &/*idManager*/, mysqlpp::StoreQueryResult &/*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBBlockPlayer::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager &/*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::BlockPlayerSuccess, &cb, GetId(), m_replyId));
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBBlockPlayer::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::BlockPlayerFailed, &cb, GetId(), m_replyId));
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database update to block a player. */
|
||||
|
||||
#ifndef _ASYNCDBBLOCKPLAYER_H_
|
||||
#define _ASYNCDBBLOCKPLAYER_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBBlockPlayer : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBBlockPlayer(unsigned queryId, unsigned replyId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBBlockPlayer();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned m_replyId;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbcreategame.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBCreateGame::AsyncDBCreateGame(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBCreateGame::~AsyncDBCreateGame()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBCreateGame::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBCreateGame::HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
query.reset();
|
||||
query
|
||||
<< "SELECT LAST_INSERT_ID()";
|
||||
mysqlpp::StoreQueryResult tmpResult = query.store();
|
||||
DB_id insertId = tmpResult[0][0];
|
||||
if (!tmpResult || tmpResult.num_rows() != 1 || insertId == 0) {
|
||||
service.post(boost::bind(&ServerDBCallback::CreateGameFailed, &cb, GetId()));
|
||||
} else {
|
||||
service.post(boost::bind(&ServerDBCallback::CreateGameSuccess, &cb, GetId()));
|
||||
idManager.AddGameId(GetId(), insertId);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBCreateGame::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::CreateGameFailed, &cb, GetId()));
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database create game query. */
|
||||
|
||||
#ifndef _ASYNCDBCREATEGAME_H_
|
||||
#define _ASYNCDBCREATEGAME_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBCreateGame : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBCreateGame(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBCreateGame();
|
||||
|
||||
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,77 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/asyncdbendgame.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBEndGame::AsyncDBEndGame(unsigned queryId, const string &preparedName, const std::list<std::string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBEndGame::~AsyncDBEndGame()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBEndGame::Init(DBIdManager& idManager)
|
||||
{
|
||||
std::list<std::string> params;
|
||||
GetParams(params);
|
||||
ostringstream paramStream;
|
||||
paramStream << idManager.GetGameDBId(GetId());
|
||||
// Add game id as last parameter (where-clause).
|
||||
params.push_back(paramStream.str());
|
||||
SetParams(params);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBEndGame::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBEndGame::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
// Nothing to do.
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBEndGame::HandleError(boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
// Ignore errors for now (as nothing important is done).
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database end game query. */
|
||||
|
||||
#ifndef _ASYNCDBENDGAME_H_
|
||||
#define _ASYNCDBENDGAME_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBEndGame : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBEndGame(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBEndGame();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbgameplace.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBGamePlace::AsyncDBGamePlace(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBGamePlace::~AsyncDBGamePlace()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBGamePlace::Init(DBIdManager& idManager)
|
||||
{
|
||||
std::list<std::string> params;
|
||||
GetParams(params);
|
||||
ostringstream paramStream;
|
||||
paramStream << idManager.GetGameDBId(GetId());
|
||||
// Add game id as first parameter (according to the order in insert).
|
||||
params.push_front(paramStream.str());
|
||||
SetParams(params);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBGamePlace::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBGamePlace::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
// No action required.
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBGamePlace::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::QueryError, &cb, "AsyncDBGamePlace: Failure."));
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database set place query. */
|
||||
|
||||
#ifndef _ASYNCDBGAMEPLACE_H_
|
||||
#define _ASYNCDBGAMEPLACE_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBGamePlace : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBGamePlace(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBGamePlace();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdblogin.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBLogin::AsyncDBLogin(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBLogin::~AsyncDBLogin()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBLogin::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBLogin::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
// No action required.
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBLogin::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::QueryError, &cb, "AsyncDBLogin: Failure."));
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database login query. */
|
||||
|
||||
#ifndef _ASYNCDBLOGIN_H_
|
||||
#define _ASYNCDBLOGIN_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBLogin : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBLogin(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBLogin();
|
||||
|
||||
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/asyncdbquery.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBQuery::~AsyncDBQuery()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database query. */
|
||||
|
||||
#ifndef _ASYNCDBQUERY_H_
|
||||
#define _ASYNCDBQUERY_H_
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <list>
|
||||
#include <mysql++.h>
|
||||
#include <db/serverdbcallback.h>
|
||||
|
||||
class DBIdManager;
|
||||
|
||||
class AsyncDBQuery
|
||||
{
|
||||
public:
|
||||
virtual ~AsyncDBQuery();
|
||||
|
||||
virtual void Init(DBIdManager& idManager) = 0;
|
||||
|
||||
virtual std::string GetPreparedName() const = 0;
|
||||
virtual void GetParams(std::list<std::string> ¶ms) const = 0;
|
||||
virtual void SetParams(const std::list<std::string> ¶ms) = 0;
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb) = 0;
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb) = 0;
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb) = 0;
|
||||
virtual bool RequiresResultSet() const = 0;
|
||||
virtual bool Next() = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbreportavatar.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBReportAvatar::AsyncDBReportAvatar(unsigned queryId, unsigned replyId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params), m_replyId(replyId)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBReportAvatar::~AsyncDBReportAvatar()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportAvatar::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportAvatar::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::ReportAvatarSuccess, &cb, GetId(), m_replyId));
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportAvatar::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::ReportAvatarFailed, &cb, GetId(), m_replyId));
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database report inappropriate avatar query. */
|
||||
|
||||
#ifndef _ASYNCDBREPORTAVATAR_H_
|
||||
#define _ASYNCDBREPORTAVATAR_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBReportAvatar : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBReportAvatar(unsigned queryId, unsigned replyId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBReportAvatar();
|
||||
|
||||
virtual void Init(DBIdManager& /*idManager*/) {}
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned m_replyId;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <dbofficial/asyncdbreportgame.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBReportGame::AsyncDBReportGame(unsigned queryId, unsigned replyId, unsigned gameId, const string &preparedName, const list<string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params), m_replyId(replyId), m_gameId(gameId)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBReportGame::~AsyncDBReportGame()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportGame::Init(DBIdManager& idManager)
|
||||
{
|
||||
std::list<std::string> params;
|
||||
GetParams(params);
|
||||
ostringstream paramStream;
|
||||
unsigned tmpGameId = idManager.GetGameDBId(m_gameId);
|
||||
if (tmpGameId) {
|
||||
paramStream << idManager.GetGameDBId(m_gameId);
|
||||
// Add game id as last parameter (where-clause).
|
||||
params.push_back(paramStream.str());
|
||||
} else {
|
||||
params.push_back("NULL");
|
||||
}
|
||||
SetParams(params);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportGame::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportGame::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::ReportGameSuccess, &cb, GetId(), m_replyId));
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBReportGame::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
service.post(boost::bind(&ServerDBCallback::ReportGameFailed, &cb, GetId(), m_replyId));
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database report inappropriate avatar query. */
|
||||
|
||||
#ifndef _ASYNCDBREPORTGAME_H_
|
||||
#define _ASYNCDBREPORTGAME_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBReportGame : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBReportGame(unsigned queryId, unsigned replyId, unsigned gameId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBReportGame();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned m_replyId;
|
||||
unsigned m_gameId;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/asyncdbupdatescore.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
AsyncDBUpdateScore::AsyncDBUpdateScore(unsigned queryId, const string &preparedName, const std::list<std::string> ¶ms)
|
||||
: SingleAsyncDBQuery(queryId, preparedName, params)
|
||||
{
|
||||
}
|
||||
|
||||
AsyncDBUpdateScore::~AsyncDBUpdateScore()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBUpdateScore::Init(DBIdManager& idManager)
|
||||
{
|
||||
std::list<std::string> params;
|
||||
GetParams(params);
|
||||
ostringstream paramStream;
|
||||
paramStream << idManager.GetGameDBId(GetId());
|
||||
// Add game id as first parameter (param for stored procedure).
|
||||
params.push_front(paramStream.str());
|
||||
SetParams(params);
|
||||
// Ensure that "update score" is only called once for a game.
|
||||
// This game id cannot be used any more, without re-init.
|
||||
idManager.RemoveGameId(GetId());
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBUpdateScore::HandleResult(mysqlpp::Query &/*query*/, DBIdManager& /*idManager*/, mysqlpp::StoreQueryResult& /*result*/, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
// This query does not produce a result.
|
||||
HandleError(service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBUpdateScore::HandleNoResult(mysqlpp::Query &/*query*/, DBIdManager& idManager, boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
idManager.RemoveGameId(GetId());
|
||||
}
|
||||
|
||||
void
|
||||
AsyncDBUpdateScore::HandleError(boost::asio::io_service &/*service*/, ServerDBCallback &/*cb*/)
|
||||
{
|
||||
// Ignore errors for now (as nothing important is done).
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Async database query to update the score. */
|
||||
|
||||
#ifndef _ASYNCDBUPDATESCORE_H_
|
||||
#define _ASYNCDBUPDATESCORE_H_
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
class AsyncDBUpdateScore : public SingleAsyncDBQuery
|
||||
{
|
||||
public:
|
||||
AsyncDBUpdateScore(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~AsyncDBUpdateScore();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,120 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/compositeasyncdbquery.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
CompositeAsyncDBQuery::CompositeAsyncDBQuery(const AsyncQueryList &queries)
|
||||
: m_list(queries), m_errorFlag(false), m_lastGameDBId(0)
|
||||
{
|
||||
m_currentQuery = m_list.begin();
|
||||
}
|
||||
|
||||
CompositeAsyncDBQuery::~CompositeAsyncDBQuery()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::Init(DBIdManager& idManager)
|
||||
{
|
||||
(*m_currentQuery)->Init(idManager);
|
||||
}
|
||||
|
||||
std::string
|
||||
CompositeAsyncDBQuery::GetPreparedName() const
|
||||
{
|
||||
return (*m_currentQuery)->GetPreparedName();
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::GetParams(std::list<std::string> ¶ms) const
|
||||
{
|
||||
(*m_currentQuery)->GetParams(params);
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::SetParams(const std::list<std::string> ¶ms)
|
||||
{
|
||||
(*m_currentQuery)->SetParams(params);
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
(*m_currentQuery)->HandleResult(query, idManager, result, service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
(*m_currentQuery)->HandleNoResult(query, idManager, service, cb);
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::HandleError(boost::asio::io_service &service, ServerDBCallback &cb)
|
||||
{
|
||||
(*m_currentQuery)->HandleError(service, cb);
|
||||
m_errorFlag = true;
|
||||
}
|
||||
|
||||
bool
|
||||
CompositeAsyncDBQuery::RequiresResultSet() const
|
||||
{
|
||||
return (*m_currentQuery)->RequiresResultSet();
|
||||
}
|
||||
|
||||
bool
|
||||
CompositeAsyncDBQuery::Next()
|
||||
{
|
||||
bool retVal = false;
|
||||
AsyncQueryList::iterator pos = m_currentQuery;
|
||||
++pos;
|
||||
if (!m_errorFlag && pos != m_list.end()) {
|
||||
m_currentQuery = pos;
|
||||
retVal = true;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
unsigned
|
||||
CompositeAsyncDBQuery::GetLastGameDBId() const
|
||||
{
|
||||
return m_lastGameDBId;
|
||||
}
|
||||
|
||||
void
|
||||
CompositeAsyncDBQuery::SetLastGameDBId(unsigned id)
|
||||
{
|
||||
m_lastGameDBId = id;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Composite async database query. */
|
||||
|
||||
#ifndef _COMPOSITEASYNCDBQUERY_H_
|
||||
#define _COMPOSITEASYNCDBQUERY_H_
|
||||
|
||||
#include <dbofficial/asyncdbquery.h>
|
||||
#include <dbofficial/querycontext.h>
|
||||
|
||||
|
||||
class CompositeAsyncDBQuery : public AsyncDBQuery, public QueryContext
|
||||
{
|
||||
public:
|
||||
typedef std::list<boost::shared_ptr<AsyncDBQuery> > AsyncQueryList;
|
||||
// Note: This list must contain at least one query.
|
||||
CompositeAsyncDBQuery(const AsyncQueryList &queries);
|
||||
virtual ~CompositeAsyncDBQuery();
|
||||
|
||||
virtual void Init(DBIdManager& idManager);
|
||||
|
||||
virtual std::string GetPreparedName() const;
|
||||
virtual void GetParams(std::list<std::string> ¶ms) const;
|
||||
virtual void SetParams(const std::list<std::string> ¶ms);
|
||||
|
||||
virtual void HandleResult(mysqlpp::Query &query, DBIdManager& idManager, mysqlpp::StoreQueryResult& result, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
virtual void HandleNoResult(mysqlpp::Query &query, DBIdManager& idManager, boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
// One error will cancel the rest of the composite query.
|
||||
virtual void HandleError(boost::asio::io_service &service, ServerDBCallback &cb);
|
||||
|
||||
virtual bool RequiresResultSet() const;
|
||||
virtual bool Next();
|
||||
|
||||
virtual unsigned GetLastGameDBId() const;
|
||||
virtual void SetLastGameDBId(unsigned id);
|
||||
|
||||
private:
|
||||
AsyncQueryList m_list;
|
||||
AsyncQueryList::iterator m_currentQuery;
|
||||
bool m_errorFlag;
|
||||
unsigned m_lastGameDBId;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _DB_TABLE_DEFS_H_
|
||||
#define _DB_TABLE_DEFS_H_
|
||||
|
||||
#define DB_TABLE_PLAYER "player_login"
|
||||
#define DB_TABLE_PLAYER_COL_ID "id"
|
||||
#define DB_TABLE_PLAYER_COL_USERNAME "username"
|
||||
#define DB_TABLE_PLAYER_COL_PASSWORD "password"
|
||||
#define DB_TABLE_PLAYER_COL_VALID "valid"
|
||||
#define DB_TABLE_PLAYER_COL_COUNTRY "country"
|
||||
#define DB_TABLE_PLAYER_COL_LASTLOGIN "last_login"
|
||||
#define DB_TABLE_PLAYER_COL_ACTIVE "aktivator"
|
||||
#define DB_TABLE_PLAYER_COL_AVATARHASH "avatar_hash"
|
||||
#define DB_TABLE_PLAYER_COL_AVATARTYPE "avatar_type"
|
||||
|
||||
#define DB_TABLE_GAME "game"
|
||||
#define DB_TABLE_GAME_COL_ID "idgame"
|
||||
#define DB_TABLE_GAME_COL_NAME "name"
|
||||
#define DB_TABLE_GAME_COL_STARTTIME "start_time"
|
||||
#define DB_TABLE_GAME_COL_ENDTIME "end_time"
|
||||
|
||||
#define DB_TABLE_GAMEPLAYER "game_has_player"
|
||||
#define DB_TABLE_GAMEPLAYER_COL_GAMEID "game_idgame"
|
||||
#define DB_TABLE_GAMEPLAYER_COL_PLAYERID "player_idplayer"
|
||||
#define DB_TABLE_GAMEPLAYER_COL_PLACE "place"
|
||||
|
||||
#define DB_TABLE_REP_AVATAR "reported_avatar"
|
||||
#define DB_TABLE_REP_AVATAR_COL_PLAYERID "idplayer"
|
||||
#define DB_TABLE_REP_AVATAR_COL_AVATARHASH "avatar_hash"
|
||||
#define DB_TABLE_REP_AVATAR_COL_AVATARTYPE "avatar_type"
|
||||
#define DB_TABLE_REP_AVATAR_COL_BY_PLAYERID "by_idplayer"
|
||||
#define DB_TABLE_REP_AVATAR_COL_TIMESTAMP "timestamp"
|
||||
|
||||
#define DB_TABLE_REP_GAME "reported_gamename"
|
||||
#define DB_TABLE_REP_GAME_COL_CREATOR "game_creator_idplayer"
|
||||
#define DB_TABLE_REP_GAME_COL_GAMEID "game_idgame"
|
||||
#define DB_TABLE_REP_GAME_COL_GAMENAME "game_name"
|
||||
#define DB_TABLE_REP_GAME_COL_BY_PLAYERID "by_idplayer"
|
||||
#define DB_TABLE_REP_GAME_COL_TIMESTAMP "timestamp"
|
||||
|
||||
#define DB_TABLE_AVATAR_BLACKLIST "avatar_blacklist"
|
||||
#define DB_TABLE_AVATAR_BLACKLIST_COL_ID "id"
|
||||
#define DB_TABLE_AVATAR_BLACKLIST_COL_AVATAR_HASH "avatar_hash"
|
||||
|
||||
#define DB_TABLE_ADMIN_PLAYER "admin_player"
|
||||
#define DB_TABLE_ADMIN_PLAYER_COL_PLAYERID "admin_idplayer"
|
||||
|
||||
#endif // DB_TABLE_DEFS_H
|
||||
@@ -0,0 +1,61 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
|
||||
|
||||
void
|
||||
DBIdManager::AddGameId(unsigned gameId, DB_id databaseId)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_gameIdMapMutex);
|
||||
m_gameIdMap[gameId] = databaseId;
|
||||
}
|
||||
|
||||
void
|
||||
DBIdManager::RemoveGameId(unsigned gameId)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_gameIdMapMutex);
|
||||
m_gameIdMap.erase(gameId);
|
||||
}
|
||||
|
||||
DB_id
|
||||
DBIdManager::GetGameDBId(unsigned gameId) const
|
||||
{
|
||||
DB_id retVal = DB_ID_INVALID;
|
||||
|
||||
boost::mutex::scoped_lock lock(m_gameIdMapMutex);
|
||||
DBMap::const_iterator pos = m_gameIdMap.find(gameId);
|
||||
if (pos != m_gameIdMap.end()) {
|
||||
retVal = pos->second;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Manager for database internal ids */
|
||||
|
||||
#ifndef _DBIDMANAGER_H_
|
||||
#define _DBIDMANAGER_H_
|
||||
|
||||
#include <db/dbdefs.h>
|
||||
#include <boost/thread.hpp>
|
||||
#include <map>
|
||||
|
||||
class DBIdManager
|
||||
{
|
||||
public:
|
||||
void AddGameId(unsigned gameId, DB_id databaseId);
|
||||
void RemoveGameId(unsigned gameId);
|
||||
|
||||
DB_id GetGameDBId(unsigned gameId) const;
|
||||
|
||||
protected:
|
||||
typedef std::map<unsigned, DB_id> DBMap;
|
||||
|
||||
private:
|
||||
DBMap m_gameIdMap;
|
||||
mutable boost::mutex m_gameIdMapMutex;
|
||||
};
|
||||
|
||||
#endif // _DBIDMANAGER_H_
|
||||
@@ -0,0 +1,36 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/querycontext.h>
|
||||
|
||||
QueryContext::~QueryContext()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Interface for a query context */
|
||||
|
||||
#ifndef _QUERYCONTEXT_H_
|
||||
#define _QUERYCONTEXT_H_
|
||||
|
||||
class QueryContext
|
||||
{
|
||||
public:
|
||||
virtual ~QueryContext();
|
||||
|
||||
virtual unsigned GetLastGameDBId() const = 0;
|
||||
virtual void SetLastGameDBId(unsigned id) = 0;
|
||||
};
|
||||
|
||||
#endif // QUERYCONTEXT_H
|
||||
@@ -0,0 +1,48 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/serverdbfactoryinternal.h>
|
||||
#include <dbofficial/serverdbthread.h>
|
||||
|
||||
|
||||
ServerDBFactoryInternal::ServerDBFactoryInternal()
|
||||
{
|
||||
}
|
||||
|
||||
ServerDBFactoryInternal::~ServerDBFactoryInternal()
|
||||
{
|
||||
}
|
||||
|
||||
boost::shared_ptr<ServerDBInterface>
|
||||
ServerDBFactoryInternal::CreateServerDBObject(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService)
|
||||
{
|
||||
return boost::shared_ptr<ServerDBInterface>(new ServerDBThread(cb, ioService));
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Server database factory for closed source db objects. */
|
||||
|
||||
#ifndef _SERVERDBFACTORYINTERNAL_H_
|
||||
#define _SERVERDBFACTORYINTERNAL_H_
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <db/serverdbinterface.h>
|
||||
#include <db/serverdbcallback.h>
|
||||
|
||||
class ServerDBFactoryInternal
|
||||
{
|
||||
public:
|
||||
ServerDBFactoryInternal();
|
||||
virtual ~ServerDBFactoryInternal();
|
||||
|
||||
virtual boost::shared_ptr<ServerDBInterface> CreateServerDBObject(
|
||||
ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService);
|
||||
};
|
||||
|
||||
typedef ServerDBFactoryInternal DBFactory;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,557 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/serverdbthread.h>
|
||||
#include <dbofficial/asyncdbauth.h>
|
||||
#include <dbofficial/asyncdblogin.h>
|
||||
#include <dbofficial/asyncdbavatarblacklist.h>
|
||||
#include <dbofficial/asyncdbcreategame.h>
|
||||
#include <dbofficial/asyncdbendgame.h>
|
||||
#include <dbofficial/asyncdbgameplace.h>
|
||||
#include <dbofficial/asyncdbupdatescore.h>
|
||||
#include <dbofficial/asyncdbreportavatar.h>
|
||||
#include <dbofficial/asyncdbreportgame.h>
|
||||
#include <dbofficial/asyncdbadminplayers.h>
|
||||
#include <dbofficial/asyncdbblockplayer.h>
|
||||
#include <dbofficial/compositeasyncdbquery.h>
|
||||
#include <dbofficial/db_table_defs.h>
|
||||
#include <ctime>
|
||||
#include <sstream>
|
||||
#include <mysql++.h>
|
||||
|
||||
#define QUERY_NICK_PREPARE "nick_template"
|
||||
#define QUERY_LOGIN_PREPARE "login_template"
|
||||
#define QUERY_AVATAR_BLACKLIST_PREPARE "avatar_blacklist_template"
|
||||
#define QUERY_CREATE_GAME_PREPARE "create_game_template"
|
||||
#define QUERY_END_GAME_PREPARE "end_game_template"
|
||||
#define QUERY_GAME_PLAYER_PREPARE "game_player_template"
|
||||
#define QUERY_UPDATE_SCORE_PREPARE "update_score_template"
|
||||
#define QUERY_REPORT_AVATAR_PREPARE "report_avatar_template"
|
||||
#define QUERY_REPORT_GAME_PREPARE "report_game_template"
|
||||
#define QUERY_ADMIN_PLAYER_PREPARE "admin_player_template"
|
||||
#define QUERY_BLOCK_PLAYER_PREPARE "block_player_template"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct DBConnectionData {
|
||||
DBConnectionData() : conn(false) {}
|
||||
string host;
|
||||
string user;
|
||||
string pwd;
|
||||
string database;
|
||||
string encryptionKey;
|
||||
mysqlpp::Connection conn;
|
||||
};
|
||||
|
||||
ServerDBThread::ServerDBThread(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService)
|
||||
: m_ioService(ioService), m_semaphore(0), m_callback(cb), m_isConnected(false), m_permanentError(false), m_previouslyConnected(false)
|
||||
{
|
||||
m_connData.reset(new DBConnectionData);
|
||||
}
|
||||
|
||||
ServerDBThread::~ServerDBThread()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::SignalTermination()
|
||||
{
|
||||
Thread::SignalTermination();
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::Init(const string &host, const string &user, const string &pwd,
|
||||
const string &database, const string &encryptionKey)
|
||||
{
|
||||
m_connData->host = host;
|
||||
m_connData->user = user;
|
||||
m_connData->pwd = pwd;
|
||||
m_connData->database = database;
|
||||
m_connData->encryptionKey = encryptionKey;
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::Start()
|
||||
{
|
||||
Run();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::Stop()
|
||||
{
|
||||
SignalTermination();
|
||||
this->Join(THREAD_WAIT_INFINITE);
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncPlayerLogin(unsigned requestId, const string &playerName)
|
||||
{
|
||||
if (IsConnected()) {
|
||||
list<string> params;
|
||||
params.push_back(m_connData->encryptionKey);
|
||||
params.push_back(playerName);
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBAuth(
|
||||
requestId,
|
||||
QUERY_NICK_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
} else {
|
||||
// If not connected to database, login fails.
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &m_callback, requestId));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncCheckAvatarBlacklist(unsigned requestId, const std::string &avatarHash)
|
||||
{
|
||||
if (IsConnected()) {
|
||||
list<string> params;
|
||||
params.push_back(avatarHash);
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBAvatarBlacklist(
|
||||
requestId,
|
||||
QUERY_AVATAR_BLACKLIST_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
} else {
|
||||
// If not connected to database, all avatars are blacklisted.
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::AvatarIsBlacklisted, &m_callback, requestId));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::PlayerPostLogin(DB_id playerId, const std::string &avatarHash, const std::string &avatarType)
|
||||
{
|
||||
list<string> params;
|
||||
params.push_back(mysqlpp::DateTime(time(NULL)));
|
||||
params.push_back(avatarHash);
|
||||
params.push_back(avatarType);
|
||||
ostringstream paramStream;
|
||||
paramStream << playerId;
|
||||
params.push_back(paramStream.str());
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBLogin(
|
||||
playerId,
|
||||
QUERY_LOGIN_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::PlayerLogout(DB_id /*playerId*/)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncCreateGame(unsigned requestId, const string &gameName)
|
||||
{
|
||||
list<string> params;
|
||||
params.push_back(gameName);
|
||||
params.push_back(mysqlpp::DateTime(time(NULL)));
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBCreateGame(
|
||||
requestId,
|
||||
QUERY_CREATE_GAME_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place)
|
||||
{
|
||||
// The game id param is added later (during init of the async op), because it may be unknown.
|
||||
list<string> params;
|
||||
ostringstream paramStream;
|
||||
paramStream << playerId;
|
||||
params.push_back(paramStream.str());
|
||||
paramStream.str("");
|
||||
paramStream << place;
|
||||
params.push_back(paramStream.str());
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBGamePlace(
|
||||
requestId,
|
||||
QUERY_GAME_PLAYER_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::EndGame(unsigned requestId)
|
||||
{
|
||||
// Set the end time of the game.
|
||||
{
|
||||
list<string> params;
|
||||
params.push_back(mysqlpp::DateTime(time(NULL)));
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBEndGame(
|
||||
requestId,
|
||||
QUERY_END_GAME_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
// Update the player scores.
|
||||
{
|
||||
list<string> params;
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBUpdateScore(
|
||||
requestId,
|
||||
QUERY_UPDATE_SCORE_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId)
|
||||
{
|
||||
list<string> params;
|
||||
ostringstream paramStream;
|
||||
paramStream << reportedPlayerId;
|
||||
params.push_back(paramStream.str());
|
||||
params.push_back(avatarHash);
|
||||
params.push_back(avatarType);
|
||||
if (byPlayerId) {
|
||||
paramStream.str("");
|
||||
paramStream << *byPlayerId;
|
||||
params.push_back(paramStream.str());
|
||||
} else {
|
||||
params.push_back("NULL");
|
||||
}
|
||||
params.push_back(mysqlpp::DateTime(time(NULL)));
|
||||
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBReportAvatar(
|
||||
requestId,
|
||||
replyId,
|
||||
QUERY_REPORT_AVATAR_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncReportGame(unsigned requestId, unsigned replyId, DB_id *creatorPlayerId, unsigned gameId, const std::string &gameName, DB_id *byPlayerId)
|
||||
{
|
||||
list<string> params;
|
||||
ostringstream paramStream;
|
||||
if (creatorPlayerId) {
|
||||
paramStream << *creatorPlayerId;
|
||||
params.push_back(paramStream.str());
|
||||
} else {
|
||||
params.push_back("NULL");
|
||||
}
|
||||
params.push_back(gameName);
|
||||
if (byPlayerId) {
|
||||
paramStream.str("");
|
||||
paramStream << *byPlayerId;
|
||||
params.push_back(paramStream.str());
|
||||
} else {
|
||||
params.push_back("NULL");
|
||||
}
|
||||
params.push_back(mysqlpp::DateTime(time(NULL)));
|
||||
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBReportGame(
|
||||
requestId,
|
||||
replyId,
|
||||
gameId,
|
||||
QUERY_REPORT_GAME_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncQueryAdminPlayers(unsigned requestId)
|
||||
{
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBAdminPlayers(
|
||||
requestId,
|
||||
QUERY_ADMIN_PLAYER_PREPARE));
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::AsyncBlockPlayer(unsigned requestId, unsigned replyId, DB_id playerId, int valid, int active)
|
||||
{
|
||||
list<string> params;
|
||||
ostringstream paramStream;
|
||||
paramStream << valid;
|
||||
params.push_back(paramStream.str());
|
||||
paramStream.str("");
|
||||
paramStream << active;
|
||||
params.push_back(paramStream.str());
|
||||
paramStream.str("");
|
||||
paramStream << playerId;
|
||||
params.push_back(paramStream.str());
|
||||
boost::shared_ptr<AsyncDBQuery> asyncQuery(
|
||||
new AsyncDBBlockPlayer(
|
||||
requestId,
|
||||
replyId,
|
||||
QUERY_BLOCK_PLAYER_PREPARE,
|
||||
params));
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
m_asyncQueue.push(asyncQuery);
|
||||
}
|
||||
m_semaphore.post();
|
||||
}
|
||||
|
||||
bool
|
||||
ServerDBThread::IsConnected() const
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_isConnectedMutex);
|
||||
return m_isConnected;
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::Main()
|
||||
{
|
||||
while (!ShouldTerminate() && !HasPermanentError()) {
|
||||
if (HasDBConnection()) {
|
||||
SetConnected(true);
|
||||
m_semaphore.wait();
|
||||
HandleNextQuery();
|
||||
} else {
|
||||
SetConnected(false);
|
||||
EstablishDBConnection();
|
||||
}
|
||||
}
|
||||
m_connData->conn.disconnect();
|
||||
}
|
||||
|
||||
bool
|
||||
ServerDBThread::HasPermanentError() const
|
||||
{
|
||||
return m_permanentError;
|
||||
}
|
||||
|
||||
bool
|
||||
ServerDBThread::HasDBConnection() const
|
||||
{
|
||||
return m_connData->conn.connected();
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::EstablishDBConnection()
|
||||
{
|
||||
m_connData->conn.set_option(new mysqlpp::SetCharsetNameOption("utf8"));
|
||||
if (!m_connData->conn.connect(
|
||||
m_connData->database.c_str(), m_connData->host.c_str(), m_connData->user.c_str(), m_connData->pwd.c_str())) {
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::ConnectFailed, &m_callback, m_connData->conn.error()));
|
||||
if (!m_previouslyConnected)
|
||||
m_permanentError = true;
|
||||
else
|
||||
Msleep(250);
|
||||
} else {
|
||||
mysqlpp::Query prepareNick = m_connData->conn.query();
|
||||
prepareNick
|
||||
<< "PREPARE " QUERY_NICK_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "SELECT " DB_TABLE_PLAYER_COL_ID ", AES_DECRYPT(" DB_TABLE_PLAYER_COL_PASSWORD ", ?), " DB_TABLE_PLAYER_COL_VALID ", TRIM(" DB_TABLE_PLAYER_COL_COUNTRY "), " DB_TABLE_PLAYER_COL_LASTLOGIN ", " DB_TABLE_PLAYER_COL_ACTIVE " FROM " DB_TABLE_PLAYER " WHERE BINARY " DB_TABLE_PLAYER_COL_USERNAME " = ?";
|
||||
mysqlpp::Query prepareAvatarBlacklist = m_connData->conn.query();
|
||||
prepareAvatarBlacklist
|
||||
<< "PREPARE " QUERY_AVATAR_BLACKLIST_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "SELECT " DB_TABLE_AVATAR_BLACKLIST_COL_ID " FROM " DB_TABLE_AVATAR_BLACKLIST " WHERE BINARY " DB_TABLE_AVATAR_BLACKLIST_COL_AVATAR_HASH " = ?";
|
||||
mysqlpp::Query prepareLogin = m_connData->conn.query();
|
||||
prepareLogin
|
||||
<< "PREPARE " QUERY_LOGIN_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "UPDATE " DB_TABLE_PLAYER " SET " DB_TABLE_PLAYER_COL_LASTLOGIN " = ?, " DB_TABLE_PLAYER_COL_AVATARHASH " = ?, " DB_TABLE_PLAYER_COL_AVATARTYPE " = ? WHERE " DB_TABLE_PLAYER_COL_ID " = ?";
|
||||
mysqlpp::Query prepareCreateGame = m_connData->conn.query();
|
||||
prepareCreateGame
|
||||
<< "PREPARE " QUERY_CREATE_GAME_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "INSERT INTO " DB_TABLE_GAME " (" DB_TABLE_GAME_COL_NAME ", " DB_TABLE_GAME_COL_STARTTIME ") VALUES (?, ?)";
|
||||
mysqlpp::Query prepareEndGame = m_connData->conn.query();
|
||||
prepareEndGame
|
||||
<< "PREPARE " QUERY_END_GAME_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "UPDATE " DB_TABLE_GAME " SET "DB_TABLE_GAME_COL_ENDTIME " = ? WHERE " DB_TABLE_GAME_COL_ID " = ?";
|
||||
mysqlpp::Query prepareRelation = m_connData->conn.query();
|
||||
prepareRelation
|
||||
<< "PREPARE " QUERY_GAME_PLAYER_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "INSERT INTO " DB_TABLE_GAMEPLAYER " (" DB_TABLE_GAMEPLAYER_COL_GAMEID ", " DB_TABLE_GAMEPLAYER_COL_PLAYERID ", " DB_TABLE_GAMEPLAYER_COL_PLACE ") VALUES (?, ?, ?)";
|
||||
mysqlpp::Query prepareScore = m_connData->conn.query();
|
||||
prepareScore
|
||||
<< "PREPARE " QUERY_UPDATE_SCORE_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "CALL updatePointsForGame(?)";
|
||||
mysqlpp::Query prepareReportAvatar = m_connData->conn.query();
|
||||
prepareReportAvatar
|
||||
<< "PREPARE " QUERY_REPORT_AVATAR_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "INSERT INTO " DB_TABLE_REP_AVATAR " (" DB_TABLE_REP_AVATAR_COL_PLAYERID ", " DB_TABLE_REP_AVATAR_COL_AVATARHASH ", " DB_TABLE_REP_AVATAR_COL_AVATARTYPE ", " DB_TABLE_REP_AVATAR_COL_BY_PLAYERID ", " DB_TABLE_REP_AVATAR_COL_TIMESTAMP ") VALUES (?, ?, ?, ?, ?)";
|
||||
mysqlpp::Query prepareReportGame = m_connData->conn.query();
|
||||
prepareReportGame
|
||||
<< "PREPARE " QUERY_REPORT_GAME_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "INSERT INTO " DB_TABLE_REP_GAME " (" DB_TABLE_REP_GAME_COL_CREATOR ", " DB_TABLE_REP_GAME_COL_GAMENAME ", " DB_TABLE_REP_GAME_COL_BY_PLAYERID ", " DB_TABLE_REP_GAME_COL_TIMESTAMP ", " DB_TABLE_REP_GAME_COL_GAMEID ") VALUES (?, ?, ?, ?, ?)";
|
||||
mysqlpp::Query prepareAdminPlayer = m_connData->conn.query();
|
||||
prepareAdminPlayer
|
||||
<< "PREPARE " QUERY_ADMIN_PLAYER_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "SELECT " DB_TABLE_ADMIN_PLAYER_COL_PLAYERID " FROM " DB_TABLE_ADMIN_PLAYER;
|
||||
mysqlpp::Query prepareBlockPlayer = m_connData->conn.query();
|
||||
prepareBlockPlayer
|
||||
<< "PREPARE " QUERY_BLOCK_PLAYER_PREPARE " FROM " << mysqlpp::quote
|
||||
<< "UPDATE " DB_TABLE_PLAYER " SET " DB_TABLE_PLAYER_COL_VALID " = ?, " DB_TABLE_PLAYER_COL_ACTIVE " = ? WHERE " DB_TABLE_PLAYER_COL_ID " = ?";
|
||||
|
||||
if (!prepareNick.exec() || !prepareAvatarBlacklist.exec() || !prepareLogin.exec() || !prepareCreateGame.exec()
|
||||
|| !prepareEndGame.exec() || !prepareRelation.exec() || !prepareScore.exec() || !prepareReportAvatar.exec()
|
||||
|| !prepareReportGame.exec() || !prepareAdminPlayer.exec() || !prepareBlockPlayer.exec()) {
|
||||
m_connData->conn.disconnect();
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::ConnectFailed, &m_callback,
|
||||
string(prepareNick.error()) + prepareAvatarBlacklist.error() + prepareLogin.error() + prepareCreateGame.error()
|
||||
+ prepareEndGame.error() + prepareRelation.error() + prepareScore.error() + prepareReportAvatar.error()
|
||||
+ prepareReportGame.error() + prepareAdminPlayer.error() + prepareBlockPlayer.error()));
|
||||
m_permanentError = true;
|
||||
} else {
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::ConnectSuccess, &m_callback));
|
||||
m_previouslyConnected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::HandleNextQuery()
|
||||
{
|
||||
boost::shared_ptr<AsyncDBQuery> nextQuery;
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_asyncQueueMutex);
|
||||
if (!m_asyncQueue.empty()) {
|
||||
nextQuery = m_asyncQueue.front();
|
||||
m_asyncQueue.pop();
|
||||
}
|
||||
}
|
||||
if (nextQuery) {
|
||||
do {
|
||||
nextQuery->Init(m_dbIdManager);
|
||||
mysqlpp::Query executeQuery = m_connData->conn.query();
|
||||
executeQuery << "EXECUTE " << nextQuery->GetPreparedName();
|
||||
|
||||
list<string> paramList;
|
||||
nextQuery->GetParams(paramList);
|
||||
if (!paramList.empty()) {
|
||||
executeQuery << " using ";
|
||||
mysqlpp::Query paramQuery = m_connData->conn.query();
|
||||
paramQuery << "SET ";
|
||||
unsigned counter = 1;
|
||||
list<string>::iterator i = paramList.begin();
|
||||
list<string>::iterator end = paramList.end();
|
||||
while (i != end) {
|
||||
if (counter > 1) {
|
||||
paramQuery << ", ";
|
||||
executeQuery << ", ";
|
||||
}
|
||||
paramQuery << "@param" << counter << " = ";
|
||||
if (*i == "NULL") {
|
||||
paramQuery << "NULL";
|
||||
} else {
|
||||
paramQuery << "_utf8" << mysqlpp::quote << *i;
|
||||
}
|
||||
executeQuery << "@param" << counter;
|
||||
++counter;
|
||||
++i;
|
||||
}
|
||||
if (!paramQuery.exec()) {
|
||||
m_connData->conn.disconnect();
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::QueryError, &m_callback, paramQuery.error()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nextQuery->RequiresResultSet()) {
|
||||
mysqlpp::StoreQueryResult res = executeQuery.store();
|
||||
if (res)
|
||||
nextQuery->HandleResult(executeQuery, m_dbIdManager, res, *m_ioService, m_callback);
|
||||
else
|
||||
nextQuery->HandleError(*m_ioService, m_callback);
|
||||
} else {
|
||||
if (executeQuery.exec())
|
||||
nextQuery->HandleNoResult(executeQuery, m_dbIdManager, *m_ioService, m_callback);
|
||||
else
|
||||
nextQuery->HandleError(*m_ioService, m_callback);
|
||||
}
|
||||
} while (nextQuery->Next()); // Consider composite queries.
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ServerDBThread::SetConnected(bool isConnected)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_isConnectedMutex);
|
||||
m_isConnected = isConnected;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Server database thread. */
|
||||
|
||||
#ifndef _SERVERDBTHREAD_H_
|
||||
#define _SERVERDBTHREAD_H_
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <queue>
|
||||
#include <db/serverdbinterface.h>
|
||||
#include <db/serverdbcallback.h>
|
||||
#include <dbofficial/dbidmanager.h>
|
||||
#include <core/thread.h>
|
||||
|
||||
struct DBConnectionData;
|
||||
class AsyncDBQuery;
|
||||
|
||||
class ServerDBThread : public ServerDBInterface, public Thread, public boost::enable_shared_from_this<ServerDBThread>
|
||||
{
|
||||
public:
|
||||
ServerDBThread(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService);
|
||||
virtual ~ServerDBThread();
|
||||
|
||||
virtual void SignalTermination();
|
||||
|
||||
virtual void Init(const std::string &host, const std::string &user, const std::string &pwd,
|
||||
const std::string &database, const std::string &encryptionKey);
|
||||
|
||||
virtual void Start();
|
||||
virtual void Stop();
|
||||
|
||||
virtual void AsyncPlayerLogin(unsigned requestId, const std::string &playerName);
|
||||
virtual void AsyncCheckAvatarBlacklist(unsigned requestId, const std::string &avatarHash);
|
||||
virtual void PlayerPostLogin(DB_id playerId, const std::string &avatarHash, const std::string &avatarType);
|
||||
virtual void PlayerLogout(DB_id playerId);
|
||||
|
||||
virtual void AsyncCreateGame(unsigned requestId, const std::string &gameName);
|
||||
virtual void SetGamePlayerPlace(unsigned requestId, DB_id playerId, unsigned place);
|
||||
virtual void EndGame(unsigned requestId);
|
||||
|
||||
virtual void AsyncReportAvatar(unsigned requestId, unsigned replyId, DB_id reportedPlayerId, const std::string &avatarHash, const std::string &avatarType, DB_id *byPlayerId);
|
||||
virtual void AsyncReportGame(unsigned requestId, unsigned replyId, DB_id *creatorPlayerId, unsigned gameId, const std::string &gameName, DB_id *byPlayerId);
|
||||
|
||||
virtual void AsyncQueryAdminPlayers(unsigned requestId);
|
||||
virtual void AsyncBlockPlayer(unsigned requestId, unsigned replyId, DB_id playerId, int valid, int active);
|
||||
|
||||
bool IsConnected() const;
|
||||
|
||||
protected:
|
||||
typedef std::queue<boost::shared_ptr<AsyncDBQuery> > AsyncDBQueryQueue;
|
||||
|
||||
// Main function of the thread.
|
||||
virtual void Main();
|
||||
|
||||
bool HasPermanentError() const;
|
||||
bool HasDBConnection() const;
|
||||
void EstablishDBConnection();
|
||||
void HandleNextQuery();
|
||||
|
||||
void SetConnected(bool isConnected);
|
||||
private:
|
||||
|
||||
boost::shared_ptr<boost::asio::io_service> m_ioService;
|
||||
boost::interprocess::interprocess_semaphore m_semaphore;
|
||||
ServerDBCallback &m_callback;
|
||||
boost::shared_ptr<DBConnectionData> m_connData;
|
||||
mutable boost::mutex m_asyncQueueMutex;
|
||||
AsyncDBQueryQueue m_asyncQueue;
|
||||
DBIdManager m_dbIdManager;
|
||||
|
||||
mutable boost::mutex m_isConnectedMutex;
|
||||
bool m_isConnected;
|
||||
bool m_permanentError;
|
||||
bool m_previouslyConnected;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include <dbofficial/singleasyncdbquery.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
SingleAsyncDBQuery::SingleAsyncDBQuery(unsigned queryId, const string &preparedName, const list<string> ¶ms)
|
||||
: m_id(queryId), m_preparedName(preparedName), m_params(params)
|
||||
{
|
||||
}
|
||||
|
||||
SingleAsyncDBQuery::~SingleAsyncDBQuery()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned
|
||||
SingleAsyncDBQuery::GetId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
std::string
|
||||
SingleAsyncDBQuery::GetPreparedName() const
|
||||
{
|
||||
return m_preparedName;
|
||||
}
|
||||
|
||||
void
|
||||
SingleAsyncDBQuery::GetParams(std::list<std::string> ¶ms) const
|
||||
{
|
||||
params = m_params;
|
||||
}
|
||||
|
||||
void
|
||||
SingleAsyncDBQuery::SetParams(const std::list<std::string> ¶ms)
|
||||
{
|
||||
m_params = params;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*****************************************************************************
|
||||
* PokerTH - The open source texas holdem engine *
|
||||
* Copyright (C) 2006-2016 Felix Hammer, Florian Thauer, Lothar May *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* *
|
||||
* Additional permission under GNU AGPL version 3 section 7 *
|
||||
* *
|
||||
* If you modify this program, or any covered work, by linking or *
|
||||
* combining it with the OpenSSL project's OpenSSL library (or a *
|
||||
* modified version of that library), containing parts covered by the *
|
||||
* terms of the OpenSSL or SSLeay licenses, the authors of PokerTH *
|
||||
* (Felix Hammer, Florian Thauer, Lothar May) grant you additional *
|
||||
* permission to convey the resulting work. *
|
||||
* Corresponding Source for a non-source form of such a combination *
|
||||
* shall include the source code for the parts of OpenSSL used as well *
|
||||
* as that of the covered work. *
|
||||
*****************************************************************************/
|
||||
/* Single (non-composite) async database query. */
|
||||
|
||||
#ifndef _SINGLEASYNCDBQUERY_H_
|
||||
#define _SINGLEASYNCDBQUERY_H_
|
||||
|
||||
#include <dbofficial/asyncdbquery.h>
|
||||
|
||||
class SingleAsyncDBQuery : public AsyncDBQuery
|
||||
{
|
||||
public:
|
||||
SingleAsyncDBQuery(unsigned queryId, const std::string &preparedName, const std::list<std::string> ¶ms);
|
||||
virtual ~SingleAsyncDBQuery();
|
||||
|
||||
unsigned GetId() const;
|
||||
virtual std::string GetPreparedName() const;
|
||||
virtual void GetParams(std::list<std::string> ¶ms) const;
|
||||
virtual void SetParams(const std::list<std::string> ¶ms);
|
||||
|
||||
virtual bool Next()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
const unsigned m_id;
|
||||
std::string m_preparedName;
|
||||
std::list<std::string> m_params;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <net/net_helper.h>
|
||||
#include <db/serverdbinterface.h>
|
||||
#ifdef POKERTH_OFFICIAL_SERVER
|
||||
#include <dbclosed/serverdbfactoryinternal.h>
|
||||
#include <dbofficial/serverdbfactoryinternal.h>
|
||||
#else
|
||||
#include <db/serverdbfactorygeneric.h>
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user