More work on rejoin: The server now detects when a rejoin is possible and allows the player to login directly, without waiting for a possible existing connection to be terminated. A session GUID is stored in the cache directory on client side for this purpose.

This commit is contained in:
lotodore
2011-08-28 17:14:03 +00:00
parent 0a49783889
commit 32ba77709e
18 changed files with 195 additions and 24 deletions
+18
View File
@@ -78,6 +78,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
string myName;
string myAvatarFile;
string myGuid;
unsigned uniqueId = 0;
PlayerType type = PLAYER_TYPE_COMPUTER;
@@ -86,12 +87,14 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
type = (*player_i)->GetType();
myName = (*player_i)->GetName();
myAvatarFile = (*player_i)->GetAvatarFile();
myGuid = (*player_i)->GetGuid();
++player_i;
}
// create player objects
boost::shared_ptr<PlayerInterface> tmpPlayer = myFactory->createPlayer(i, uniqueId, type, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0);
tmpPlayer->setIsConnected(true);
tmpPlayer->setMyGuid(myGuid);
// fill player lists
seatsList->push_back(tmpPlayer);
@@ -219,6 +222,21 @@ boost::shared_ptr<PlayerInterface> Game::getCurrentPlayer()
return tmpPlayer;
}
boost::shared_ptr<PlayerInterface> Game::getPlayerByName(const std::string &name)
{
boost::shared_ptr<PlayerInterface> tmpPlayer;
PlayerListIterator i = getSeatsList()->begin();
PlayerListIterator end = getSeatsList()->end();
while (i != end) {
if ((*i)->getMyName() == name) {
tmpPlayer = *i;
break;
}
++i;
}
return tmpPlayer;
}
void Game::raiseBlinds()
{
+1
View File
@@ -104,6 +104,7 @@ public:
}
boost::shared_ptr<PlayerInterface> getPlayerByUniqueId(unsigned id);
boost::shared_ptr<PlayerInterface> getPlayerByName(const std::string &name);
boost::shared_ptr<PlayerInterface> getCurrentPlayer();
void raiseBlinds();
+10
View File
@@ -43,6 +43,15 @@ public:
unsigned getMyUniqueID() const {
return myUniqueID;
}
void setMyGuid(const std::string &theValue) {
myGuid = theValue;
}
std::string getMyGuid() const {
return myGuid;
}
PlayerType getMyType() const {
return myType;
}
@@ -290,6 +299,7 @@ private:
// Konstanten
int myID;
unsigned myUniqueID;
std::string myGuid;
PlayerType myType;
std::string myName;
std::string myAvatar;
@@ -60,9 +60,23 @@ ClientPlayer::getMyUniqueID() const
return myUniqueID;
}
void
ClientPlayer::setMyGuid(const std::string &theValue)
{
myGuid = theValue;
}
std::string
ClientPlayer::getMyGuid() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myGuid;
}
PlayerType
ClientPlayer::getMyType() const
{
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
return myType;
}
+3
View File
@@ -38,6 +38,8 @@ public:
int getMyID() const;
unsigned getMyUniqueID() const;
void setMyGuid(const std::string &theValue);
std::string getMyGuid() const;
PlayerType getMyType() const;
void setMyDude(int theValue);
@@ -151,6 +153,7 @@ private:
// Konstanten
const int myID;
const unsigned myUniqueID;
std::string myGuid;
const PlayerType myType;
std::string myName;
std::string myAvatar;
+4
View File
@@ -34,6 +34,10 @@ public:
virtual int getMyID() const =0;
virtual unsigned getMyUniqueID() const =0;
virtual void setMyGuid(const std::string &theValue) =0;
virtual std::string getMyGuid() const =0;
virtual PlayerType getMyType() const =0;
virtual void setMyDude(int theValue) =0;