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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user