Starting login dialog integration on client side.
This commit is contained in:
@@ -30,7 +30,7 @@ ServerDBFactoryGeneric::~ServerDBFactoryGeneric()
|
||||
}
|
||||
|
||||
boost::shared_ptr<ServerDBInterface>
|
||||
ServerDBFactoryGeneric::CreateServerDBObject(ServerDBCallback &/*cb*/, boost::shared_ptr<boost::asio::io_service> /*ioService*/)
|
||||
ServerDBFactoryGeneric::CreateServerDBObject(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService)
|
||||
{
|
||||
return boost::shared_ptr<ServerDBInterface>(new ServerDBGeneric);
|
||||
return boost::shared_ptr<ServerDBInterface>(new ServerDBGeneric(cb, ioService));
|
||||
}
|
||||
|
||||
@@ -17,12 +17,14 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <db/serverdbgeneric.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
ServerDBGeneric::ServerDBGeneric()
|
||||
ServerDBGeneric::ServerDBGeneric(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService)
|
||||
: m_ioService(ioService), m_callback(cb)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -36,10 +38,10 @@ ServerDBGeneric::Init(const string &/*host*/, const string &/*user*/, const stri
|
||||
{
|
||||
}
|
||||
|
||||
async_handle
|
||||
ServerDBGeneric::AsyncPlayerLogin(const string &/*playerName*/, const string &/*secretString*/)
|
||||
void
|
||||
ServerDBGeneric::AsyncPlayerLogin(unsigned requestId, const string &/*playerName*/, const string &/*secretString*/)
|
||||
{
|
||||
return ASYNC_HANDLE_INVALID;
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::PlayerLoginFailed, &m_callback, requestId));
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -48,10 +50,10 @@ ServerDBGeneric::PlayerLogout(db_id /*playerId*/)
|
||||
return false;
|
||||
}
|
||||
|
||||
async_handle
|
||||
ServerDBGeneric::AsyncCreateGame(const db_list &/*players*/)
|
||||
void
|
||||
ServerDBGeneric::AsyncCreateGame(unsigned requestId, const db_list &/*players*/)
|
||||
{
|
||||
return ASYNC_HANDLE_INVALID;
|
||||
m_ioService->post(boost::bind(&ServerDBCallback::CreateGameFailed, &m_callback, requestId));
|
||||
}
|
||||
|
||||
bool
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
#include <string>
|
||||
|
||||
typedef unsigned db_id;
|
||||
typedef unsigned async_handle;
|
||||
#define DB_ID_INVALID 0
|
||||
#define ASYNC_HANDLE_INVALID 0
|
||||
|
||||
// Callback operations are posted using the io service,
|
||||
// and will therefore be executed in the io service thread.
|
||||
@@ -38,11 +36,11 @@ public:
|
||||
virtual void ConnectSuccess() = 0;
|
||||
virtual void ConnectFailed(const std::string &error) = 0;
|
||||
|
||||
virtual void PlayerLoginSuccess(async_handle login, db_id playerId) = 0;
|
||||
virtual void PlayerLoginFailed(async_handle login) = 0;
|
||||
virtual void PlayerLoginSuccess(unsigned requestId, db_id playerId) = 0;
|
||||
virtual void PlayerLoginFailed(unsigned requestId) = 0;
|
||||
|
||||
virtual void CreateGameSuccess(async_handle create, db_id gameId) = 0;
|
||||
virtual void CreateGameFailed(async_handle create) = 0;
|
||||
virtual void CreateGameSuccess(unsigned requestId, db_id gameId) = 0;
|
||||
virtual void CreateGameFailed(unsigned requestId) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,24 +21,30 @@
|
||||
#ifndef _SERVERDBGENERIC_H_
|
||||
#define _SERVERDBGENERIC_H_
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <db/serverdbinterface.h>
|
||||
|
||||
|
||||
class ServerDBGeneric : public ServerDBInterface
|
||||
{
|
||||
public:
|
||||
ServerDBGeneric();
|
||||
ServerDBGeneric(ServerDBCallback &cb, boost::shared_ptr<boost::asio::io_service> ioService);
|
||||
virtual ~ServerDBGeneric();
|
||||
|
||||
virtual void Init(const std::string &host, const std::string &user, const std::string &pwd,
|
||||
const std::string &database, const std::string &encryptionKey);
|
||||
|
||||
virtual async_handle AsyncPlayerLogin(const std::string &playerName, const std::string &secretString);
|
||||
virtual void AsyncPlayerLogin(unsigned requestId, const std::string &playerName, const std::string &secretString);
|
||||
virtual bool PlayerLogout(db_id playerId);
|
||||
|
||||
virtual async_handle AsyncCreateGame(const db_list &players);
|
||||
virtual void AsyncCreateGame(unsigned requestId, const db_list &players);
|
||||
virtual bool SetGamePlayerPlace(db_id gameId, db_id playerId, unsigned place);
|
||||
virtual bool EndGame(db_id gameId);
|
||||
|
||||
private:
|
||||
boost::shared_ptr<boost::asio::io_service> m_ioService;
|
||||
ServerDBCallback &m_callback;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -35,10 +35,10 @@ public:
|
||||
virtual void Init(const std::string &host, const std::string &user, const std::string &pwd,
|
||||
const std::string &database, const std::string &encryptionKey) = 0;
|
||||
|
||||
virtual async_handle AsyncPlayerLogin(const std::string &playerName, const std::string &secretString) = 0;
|
||||
virtual void AsyncPlayerLogin(unsigned requestId, const std::string &playerName, const std::string &secretString) = 0;
|
||||
virtual bool PlayerLogout(db_id playerId) = 0;
|
||||
|
||||
virtual async_handle AsyncCreateGame(const db_list &players) = 0;
|
||||
virtual void AsyncCreateGame(unsigned requestId, const db_list &players) = 0;
|
||||
virtual bool SetGamePlayerPlace(db_id gameId, db_id playerId, unsigned place) = 0;
|
||||
virtual bool EndGame(db_id gameId) = 0;
|
||||
};
|
||||
|
||||
@@ -60,8 +60,8 @@ public:
|
||||
bool ipv6,
|
||||
bool sctp,
|
||||
const std::string &avatarServerAddress,
|
||||
const std::string &pwd,
|
||||
const std::string &playerName,
|
||||
const std::string &playerPwd,
|
||||
const std::string &avatarFile,
|
||||
const std::string &cacheDir);
|
||||
virtual void SignalTermination();
|
||||
|
||||
@@ -84,8 +84,8 @@ void
|
||||
ClientThread::Init(
|
||||
const string &serverAddress, const string &serverListUrl,
|
||||
bool useServerList, unsigned serverPort, bool ipv6, bool sctp,
|
||||
const string &avatarServerAddress, const string &pwd,
|
||||
const string &playerName, const string &avatarFile,
|
||||
const string &avatarServerAddress, const string &playerName,
|
||||
const string &playerPwd, const string &avatarFile,
|
||||
const string &cacheDir)
|
||||
{
|
||||
if (IsRunning())
|
||||
@@ -103,8 +103,8 @@ ClientThread::Init(
|
||||
context.SetUseServerList(useServerList);
|
||||
context.SetServerPort(serverPort);
|
||||
context.SetAvatarServerAddr(avatarServerAddress);
|
||||
context.SetPassword(pwd);
|
||||
context.SetPlayerName(playerName);
|
||||
context.SetPassword(playerPwd);
|
||||
context.SetAvatarFile(avatarFile);
|
||||
context.SetCacheDir(cacheDir);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <net/socket_msg.h>
|
||||
#include <net/chatcleanermanager.h>
|
||||
#include <db/serverdbinterface.h>
|
||||
#include <db/serverdbcallback.h>
|
||||
#ifdef POKERTH_OFFICIAL_SERVER
|
||||
#include <dbclosed/serverdbfactoryinternal.h>
|
||||
#else
|
||||
@@ -105,19 +104,21 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual void PlayerLoginSuccess(async_handle login, db_id playerId)
|
||||
virtual void PlayerLoginSuccess(unsigned requestId, db_id dbPlayerId)
|
||||
{
|
||||
m_server.AuthenticationSuccess(requestId, dbPlayerId);
|
||||
}
|
||||
|
||||
virtual void PlayerLoginFailed(unsigned requestId)
|
||||
{
|
||||
m_server.AuthenticationFailure(requestId);
|
||||
}
|
||||
|
||||
virtual void CreateGameSuccess(unsigned requestId, db_id gameId)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void PlayerLoginFailed(async_handle login)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void CreateGameSuccess(async_handle create, db_id gameId)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void CreateGameFailed(async_handle create)
|
||||
virtual void CreateGameFailed(unsigned requestId)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1255,7 +1256,18 @@ ServerLobbyThread::EstablishSession(SessionWrapper session)
|
||||
void
|
||||
ServerLobbyThread::AuthenticatePlayer(SessionWrapper session, const std::string &password)
|
||||
{
|
||||
// TODO
|
||||
assert(session.playerData);
|
||||
m_database->AsyncPlayerLogin(session.playerData->GetUniqueId(), session.playerData->GetName(), password);
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::AuthenticationSuccess(unsigned playerId, db_id dbPlayerId)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
ServerLobbyThread::AuthenticationFailure(unsigned playerId)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <net/sessionmanager.h>
|
||||
#include <net/netpacket.h>
|
||||
#include <db/serverdbcallback.h>
|
||||
#include <gui/guiinterface.h>
|
||||
#include <gamedata.h>
|
||||
|
||||
@@ -133,6 +134,8 @@ protected:
|
||||
void InitAfterLogin(SessionWrapper session);
|
||||
void EstablishSession(SessionWrapper session);
|
||||
void AuthenticatePlayer(SessionWrapper session, const std::string &password);
|
||||
void AuthenticationSuccess(unsigned playerId, db_id dbPlayerId);
|
||||
void AuthenticationFailure(unsigned playerId);
|
||||
void RequestPlayerAvatar(SessionWrapper session);
|
||||
void TimerRemoveGame(const boost::system::error_code &ec);
|
||||
void TimerRemovePlayer(const boost::system::error_code &ec);
|
||||
@@ -232,6 +235,8 @@ private:
|
||||
boost::asio::deadline_timer m_avatarLockTimer;
|
||||
|
||||
const boost::posix_time::ptime m_startTime;
|
||||
|
||||
friend class InternalServerCallback;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+5
-5
@@ -154,7 +154,7 @@ boost::shared_ptr<AvatarManager> Session::getAvatarManager()
|
||||
return myAvatarManager;
|
||||
}
|
||||
|
||||
void Session::startInternetClient()
|
||||
void Session::startInternetClient(const std::string &username, const std::string &password)
|
||||
{
|
||||
if (myNetClient || !myGui)
|
||||
{
|
||||
@@ -178,8 +178,8 @@ void Session::startInternetClient()
|
||||
myConfig->readConfigInt("InternetServerUseIpv6") == 1,
|
||||
myConfig->readConfigInt("InternetServerUseSctp") == 1,
|
||||
useAvatarServer ? myConfig->readConfigString("AvatarServerAddress") : "",
|
||||
myConfig->readConfigString("InternetServerPassword"),
|
||||
myConfig->readConfigString("MyName"),
|
||||
username,
|
||||
password,
|
||||
myConfig->readConfigString("MyAvatar"),
|
||||
myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir")));
|
||||
myNetClient->Run();
|
||||
@@ -203,8 +203,8 @@ void Session::startNetworkClient(const string &serverAddress, unsigned serverPor
|
||||
ipv6,
|
||||
sctp,
|
||||
"", // no avatar server
|
||||
pwd,
|
||||
myConfig->readConfigString("MyName"),
|
||||
pwd,
|
||||
myConfig->readConfigString("MyAvatar"),
|
||||
myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir")));
|
||||
myNetClient->Run();
|
||||
@@ -231,8 +231,8 @@ void Session::startNetworkClientForLocalServer(const GameData &gameData)
|
||||
useIpv6,
|
||||
myConfig->readConfigInt("ServerUseSctp") == 1,
|
||||
"", // no avatar server
|
||||
myConfig->readConfigString("ServerPassword"),
|
||||
myConfig->readConfigString("MyName"),
|
||||
myConfig->readConfigString("ServerPassword"),
|
||||
myConfig->readConfigString("MyAvatar"),
|
||||
myQtToolsInterface->stringFromUtf8(myConfig->readConfigString("CacheDir")));
|
||||
myNetClient->Run();
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public:
|
||||
|
||||
boost::shared_ptr<AvatarManager> getAvatarManager();
|
||||
|
||||
void startInternetClient();
|
||||
void startInternetClient(const std::string &username, const std::string &password);
|
||||
void startNetworkClient(const std::string &serverAddress, unsigned serverPort, bool ipv6, bool sctp, const std::string &pwd);
|
||||
void startNetworkClientForLocalServer(const GameData &gameData);
|
||||
void terminateNetworkClient();
|
||||
|
||||
Reference in New Issue
Block a user