More work on new network protocol.
This commit is contained in:
+25
-7
@@ -390,7 +390,7 @@ protected:
|
|||||||
|
|
||||||
virtual void InternalHandleAnnounceMsg(boost::shared_ptr<ClientThread> /*client*/, const AnnounceMessage &/*announceMsg*/) {}
|
virtual void InternalHandleAnnounceMsg(boost::shared_ptr<ClientThread> /*client*/, const AnnounceMessage &/*announceMsg*/) {}
|
||||||
virtual void InternalHandleAuthMsg(boost::shared_ptr<ClientThread> /*client*/, const AuthMessage &/*authMsg*/) {}
|
virtual void InternalHandleAuthMsg(boost::shared_ptr<ClientThread> /*client*/, const AuthMessage &/*authMsg*/) {}
|
||||||
virtual void InternalHandleLobbyMsg(boost::shared_ptr<ClientThread> /*client*/, const LobbyMessage &/*lobbyMsg*/) {}
|
virtual void InternalHandleLobbyMsg(boost::shared_ptr<ClientThread> client, const LobbyMessage &lobbyMsg);
|
||||||
virtual void InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg);
|
virtual void InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -410,7 +410,10 @@ protected:
|
|||||||
// Protected constructor - this is a singleton.
|
// Protected constructor - this is a singleton.
|
||||||
ClientStateWaitGame();
|
ClientStateWaitGame();
|
||||||
|
|
||||||
virtual void InternalHandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket);
|
virtual void InternalHandleAnnounceMsg(boost::shared_ptr<ClientThread> /*client*/, const AnnounceMessage &/*announceMsg*/) {}
|
||||||
|
virtual void InternalHandleAuthMsg(boost::shared_ptr<ClientThread> /*client*/, const AuthMessage &/*authMsg*/) {}
|
||||||
|
virtual void InternalHandleLobbyMsg(boost::shared_ptr<ClientThread> client, const LobbyMessage &lobbyMsg);
|
||||||
|
virtual void InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg);
|
||||||
};
|
};
|
||||||
|
|
||||||
// State: Synchronize on game start.
|
// State: Synchronize on game start.
|
||||||
@@ -430,7 +433,10 @@ protected:
|
|||||||
ClientStateSynchronizeStart();
|
ClientStateSynchronizeStart();
|
||||||
|
|
||||||
void TimerLoop(const boost::system::error_code& ec, boost::shared_ptr<ClientThread> client);
|
void TimerLoop(const boost::system::error_code& ec, boost::shared_ptr<ClientThread> client);
|
||||||
virtual void InternalHandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket);
|
virtual void InternalHandleAnnounceMsg(boost::shared_ptr<ClientThread> /*client*/, const AnnounceMessage &/*announceMsg*/) {}
|
||||||
|
virtual void InternalHandleAuthMsg(boost::shared_ptr<ClientThread> /*client*/, const AuthMessage &/*authMsg*/) {}
|
||||||
|
virtual void InternalHandleLobbyMsg(boost::shared_ptr<ClientThread> /*client*/, const LobbyMessage &/*lobbyMsg*/) {}
|
||||||
|
virtual void InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg);
|
||||||
};
|
};
|
||||||
|
|
||||||
// State: Wait for game start.
|
// State: Wait for game start.
|
||||||
@@ -449,7 +455,10 @@ protected:
|
|||||||
// Protected constructor - this is a singleton.
|
// Protected constructor - this is a singleton.
|
||||||
ClientStateWaitStart();
|
ClientStateWaitStart();
|
||||||
|
|
||||||
virtual void InternalHandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket);
|
virtual void InternalHandleAnnounceMsg(boost::shared_ptr<ClientThread> /*client*/, const AnnounceMessage &/*announceMsg*/) {}
|
||||||
|
virtual void InternalHandleAuthMsg(boost::shared_ptr<ClientThread> /*client*/, const AuthMessage &/*authMsg*/) {}
|
||||||
|
virtual void InternalHandleLobbyMsg(boost::shared_ptr<ClientThread> /*client*/, const LobbyMessage &/*lobbyMsg*/) {}
|
||||||
|
virtual void InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg);
|
||||||
};
|
};
|
||||||
|
|
||||||
// State: Wait for start of the next hand.
|
// State: Wait for start of the next hand.
|
||||||
@@ -468,7 +477,10 @@ protected:
|
|||||||
// Protected constructor - this is a singleton.
|
// Protected constructor - this is a singleton.
|
||||||
ClientStateWaitHand();
|
ClientStateWaitHand();
|
||||||
|
|
||||||
virtual void InternalHandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket);
|
virtual void InternalHandleAnnounceMsg(boost::shared_ptr<ClientThread> /*client*/, const AnnounceMessage &/*announceMsg*/) {}
|
||||||
|
virtual void InternalHandleAuthMsg(boost::shared_ptr<ClientThread> /*client*/, const AuthMessage &/*authMsg*/) {}
|
||||||
|
virtual void InternalHandleLobbyMsg(boost::shared_ptr<ClientThread> /*client*/, const LobbyMessage &/*lobbyMsg*/) {}
|
||||||
|
virtual void InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg);
|
||||||
};
|
};
|
||||||
|
|
||||||
// State: Hand Loop.
|
// State: Hand Loop.
|
||||||
@@ -487,7 +499,10 @@ protected:
|
|||||||
// Protected constructor - this is a singleton.
|
// Protected constructor - this is a singleton.
|
||||||
ClientStateRunHand();
|
ClientStateRunHand();
|
||||||
|
|
||||||
virtual void InternalHandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket);
|
virtual void InternalHandleAnnounceMsg(boost::shared_ptr<ClientThread> /*client*/, const AnnounceMessage &/*announceMsg*/) {}
|
||||||
|
virtual void InternalHandleAuthMsg(boost::shared_ptr<ClientThread> /*client*/, const AuthMessage &/*authMsg*/) {}
|
||||||
|
virtual void InternalHandleLobbyMsg(boost::shared_ptr<ClientThread> /*client*/, const LobbyMessage &/*lobbyMsg*/) {}
|
||||||
|
virtual void InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg);
|
||||||
|
|
||||||
static void ResetPlayerActions(Game &curGame);
|
static void ResetPlayerActions(Game &curGame);
|
||||||
static void ResetPlayerSets(Game &curGame);
|
static void ResetPlayerSets(Game &curGame);
|
||||||
@@ -502,7 +517,10 @@ public:
|
|||||||
virtual void Enter(boost::shared_ptr<ClientThread> /*client*/) {}
|
virtual void Enter(boost::shared_ptr<ClientThread> /*client*/) {}
|
||||||
virtual void Exit(boost::shared_ptr<ClientThread> /*client*/) {}
|
virtual void Exit(boost::shared_ptr<ClientThread> /*client*/) {}
|
||||||
|
|
||||||
virtual void HandlePacket(boost::shared_ptr<ClientThread> /*client*/, boost::shared_ptr<NetPacket> /*tmpPacket*/) {}
|
virtual void HandleAnnounceMsg(boost::shared_ptr<ClientThread> /*client*/, const AnnounceMessage &/*announceMsg*/) {}
|
||||||
|
virtual void HandleAuthMsg(boost::shared_ptr<ClientThread> /*client*/, const AuthMessage &/*authMsg*/) {}
|
||||||
|
virtual void HandleLobbyMsg(boost::shared_ptr<ClientThread> /*client*/, const LobbyMessage &/*lobbyMsg*/) {}
|
||||||
|
virtual void HandleGameMsg(boost::shared_ptr<ClientThread> /*client*/, const GameMessage &/*gameMsg*/) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Protected constructor - this is a singleton.
|
// Protected constructor - this is a singleton.
|
||||||
|
|||||||
+165
-119
@@ -1205,7 +1205,7 @@ ClientStateWaitAuthVerify::Exit(boost::shared_ptr<ClientThread> /*client*/)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientStateWaitAuthChallenge::InternalHandleAuthMsg(boost::shared_ptr<ClientThread> client, const AuthMessage &authMsg)
|
ClientStateWaitAuthVerify::InternalHandleAuthMsg(boost::shared_ptr<ClientThread> client, const AuthMessage &authMsg)
|
||||||
{
|
{
|
||||||
if (authMsg.messagetype() == AuthMessage::Type_AuthServerVerificationMessage) {
|
if (authMsg.messagetype() == AuthMessage::Type_AuthServerVerificationMessage) {
|
||||||
// Check subtype.
|
// Check subtype.
|
||||||
@@ -1319,14 +1319,50 @@ ClientStateWaitJoin::Exit(boost::shared_ptr<ClientThread> /*client*/)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientStateWaitJoin::InternalHandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket)
|
ClientStateWaitJoin::InternalHandleLobbyMsg(boost::shared_ptr<ClientThread> client, const LobbyMessage &lobbyMsg)
|
||||||
|
{
|
||||||
|
if (lobbyMsg.messagetype() == LobbyMessage::Type_CreateGameFailedMessage) {
|
||||||
|
// Failed to create a new game.
|
||||||
|
const CreateGameFailedMessage &netCreateFailed = lobbyMsg.creategamefailedmessage();
|
||||||
|
|
||||||
|
int failureCode;
|
||||||
|
switch (netCreateFailed.creategamefailurereason()) {
|
||||||
|
case CreateGameFailedMessage::notAllowedAsGuest:
|
||||||
|
failureCode = NTF_NET_JOIN_GUEST_FORBIDDEN;
|
||||||
|
break;
|
||||||
|
case CreateGameFailedMessage::gameNameInUse:
|
||||||
|
failureCode = NTF_NET_JOIN_GAME_NAME_IN_USE;
|
||||||
|
break;
|
||||||
|
case CreateGameFailedMessage::badGameName:
|
||||||
|
failureCode = NTF_NET_JOIN_GAME_BAD_NAME;
|
||||||
|
break;
|
||||||
|
case CreateGameFailedMessage::invalidSettings:
|
||||||
|
failureCode = NTF_NET_JOIN_INVALID_SETTINGS;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
failureCode = NTF_NET_INTERNAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
client->GetCallback().SignalNetClientNotification(failureCode);
|
||||||
|
} else if (lobbyMsg.messagetype() == LobbyMessage::Type_InviteNotifyMessage) {
|
||||||
|
const InviteNotifyMessage &netInvNotify = lobbyMsg.invitenotifymessage();
|
||||||
|
if (netInvNotify.playeridwho() == client->GetGuiPlayerId()) {
|
||||||
|
client->GetCallback().SignalSelfGameInvitation(netInvNotify.gameid(), netInvNotify.playeridbywhom());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientStateWaitJoin::InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg)
|
||||||
{
|
{
|
||||||
ClientContext &context = client->GetContext();
|
ClientContext &context = client->GetContext();
|
||||||
|
|
||||||
if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_JoinGameAckMessage) {
|
if (gameMsg.messagetype() == GameMessage::Type_GameManagementMessage) {
|
||||||
const JoinGameAckMessage &netJoinAck = tmpPacket->GetMsg()->joingameackmessage();
|
const GameManagementMessage &managementMsg = gameMsg.gamemanagementmessage();
|
||||||
|
if (managementMsg.messagetype() == GameManagementMessage::Type_JoinGameAckMessage) {
|
||||||
|
const JoinGameAckMessage &netJoinAck = managementMsg.joingameackmessage();
|
||||||
// Successfully joined a game.
|
// Successfully joined a game.
|
||||||
client->SetGameId(netJoinAck.gameid());
|
client->SetGameId(gameMsg.gameid());
|
||||||
GameData tmpData;
|
GameData tmpData;
|
||||||
NetPacket::GetGameData(netJoinAck.gameinfo(), tmpData);
|
NetPacket::GetGameData(netJoinAck.gameinfo(), tmpData);
|
||||||
client->SetGameData(tmpData);
|
client->SetGameData(tmpData);
|
||||||
@@ -1342,55 +1378,39 @@ ClientStateWaitJoin::InternalHandlePacket(boost::shared_ptr<ClientThread> client
|
|||||||
|
|
||||||
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_JOIN);
|
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_JOIN);
|
||||||
client->SetState(ClientStateWaitGame::Instance());
|
client->SetState(ClientStateWaitGame::Instance());
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_JoinGameFailedMessage) {
|
} else if (managementMsg.messagetype() == GameManagementMessage::Type_JoinGameFailedMessage) {
|
||||||
// Failed to join a game.
|
// Failed to join a game.
|
||||||
const JoinGameFailedMessage &netJoinFailed = tmpPacket->GetMsg()->joingamefailedmessage();
|
const JoinGameFailedMessage &netJoinFailed = managementMsg.joingamefailedmessage();
|
||||||
|
|
||||||
int failureCode;
|
int failureCode;
|
||||||
switch (netJoinFailed.joingamefailurereason()) {
|
switch (netJoinFailed.joingamefailurereason()) {
|
||||||
case JoinGameFailedMessage::invalidGame :
|
case JoinGameFailedMessage::invalidGame:
|
||||||
failureCode = NTF_NET_JOIN_GAME_INVALID;
|
failureCode = NTF_NET_JOIN_GAME_INVALID;
|
||||||
break;
|
break;
|
||||||
case JoinGameFailedMessage::gameIsFull :
|
case JoinGameFailedMessage::gameIsFull:
|
||||||
failureCode = NTF_NET_JOIN_GAME_FULL;
|
failureCode = NTF_NET_JOIN_GAME_FULL;
|
||||||
break;
|
break;
|
||||||
case JoinGameFailedMessage::gameIsRunning :
|
case JoinGameFailedMessage::gameIsRunning:
|
||||||
failureCode = NTF_NET_JOIN_ALREADY_RUNNING;
|
failureCode = NTF_NET_JOIN_ALREADY_RUNNING;
|
||||||
break;
|
break;
|
||||||
case JoinGameFailedMessage::invalidPassword :
|
case JoinGameFailedMessage::invalidPassword:
|
||||||
failureCode = NTF_NET_JOIN_INVALID_PASSWORD;
|
failureCode = NTF_NET_JOIN_INVALID_PASSWORD;
|
||||||
break;
|
break;
|
||||||
case JoinGameFailedMessage::notAllowedAsGuest :
|
case JoinGameFailedMessage::notInvited:
|
||||||
failureCode = NTF_NET_JOIN_GUEST_FORBIDDEN;
|
|
||||||
break;
|
|
||||||
case JoinGameFailedMessage::notInvited :
|
|
||||||
failureCode = NTF_NET_JOIN_NOT_INVITED;
|
failureCode = NTF_NET_JOIN_NOT_INVITED;
|
||||||
break;
|
break;
|
||||||
case JoinGameFailedMessage::gameNameInUse :
|
case JoinGameFailedMessage::ipAddressBlocked:
|
||||||
failureCode = NTF_NET_JOIN_GAME_NAME_IN_USE;
|
|
||||||
break;
|
|
||||||
case JoinGameFailedMessage::badGameName :
|
|
||||||
failureCode = NTF_NET_JOIN_GAME_BAD_NAME;
|
|
||||||
break;
|
|
||||||
case JoinGameFailedMessage::invalidSettings :
|
|
||||||
failureCode = NTF_NET_JOIN_INVALID_SETTINGS;
|
|
||||||
break;
|
|
||||||
case JoinGameFailedMessage::ipAddressBlocked :
|
|
||||||
failureCode = NTF_NET_JOIN_IP_BLOCKED;
|
failureCode = NTF_NET_JOIN_IP_BLOCKED;
|
||||||
break;
|
break;
|
||||||
case JoinGameFailedMessage::rejoinFailed :
|
case JoinGameFailedMessage::rejoinFailed:
|
||||||
failureCode = NTF_NET_JOIN_REJOIN_FAILED;
|
failureCode = NTF_NET_JOIN_REJOIN_FAILED;
|
||||||
break;
|
break;
|
||||||
default :
|
default:
|
||||||
failureCode = NTF_NET_INTERNAL;
|
failureCode = NTF_NET_INTERNAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
client->GetCallback().SignalNetClientNotification(failureCode);
|
client->GetCallback().SignalNetClientNotification(failureCode);
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_InviteNotifyMessage) {
|
|
||||||
const InviteNotifyMessage &netInvNotify = tmpPacket->GetMsg()->invitenotifymessage();
|
|
||||||
if (netInvNotify.playeridwho() == client->GetGuiPlayerId()) {
|
|
||||||
client->GetCallback().SignalSelfGameInvitation(netInvNotify.gameid(), netInvNotify.playeridbywhom());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1422,6 +1442,24 @@ ClientStateWaitGame::Exit(boost::shared_ptr<ClientThread> /*client*/)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientStateWaitGame::InternalHandleLobbyMsg(boost::shared_ptr<ClientThread> client, const LobbyMessage &lobbyMsg)
|
||||||
|
{
|
||||||
|
if (lobbyMsg.messagetype() == LobbyMessage::Type_InviteNotifyMessage) {
|
||||||
|
const InviteNotifyMessage &netInvNotify = lobbyMsg.invitenotifymessage();
|
||||||
|
client->GetCallback().SignalPlayerGameInvitation(
|
||||||
|
netInvNotify.gameid(),
|
||||||
|
netInvNotify.playeridwho(),
|
||||||
|
netInvNotify.playeridbywhom());
|
||||||
|
} else if (lobbyMsg.messagetype() == LobbyMessage::Type_RejectInvNotifyMessage) {
|
||||||
|
const RejectInvNotifyMessage &netRejNotify = lobbyMsg.rejectinvnotifymessage();
|
||||||
|
client->GetCallback().SignalRejectedGameInvitation(
|
||||||
|
netRejNotify.gameid(),
|
||||||
|
netRejNotify.playerid(),
|
||||||
|
static_cast<DenyGameInvitationReason>(netRejNotify.playerrejectreason()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientStateWaitGame::InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg)
|
ClientStateWaitGame::InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg)
|
||||||
{
|
{
|
||||||
@@ -1432,23 +1470,10 @@ ClientStateWaitGame::InternalHandleGameMsg(boost::shared_ptr<ClientThread> clien
|
|||||||
const StartEventMessage &netStartEvent = managementMsg.starteventmessage();
|
const StartEventMessage &netStartEvent = managementMsg.starteventmessage();
|
||||||
if (netStartEvent.starteventtype() == StartEventMessage::rejoinEvent) {
|
if (netStartEvent.starteventtype() == StartEventMessage::rejoinEvent) {
|
||||||
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_SYNCREJOIN);
|
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_SYNCREJOIN);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_SYNCSTART);
|
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_SYNCSTART);
|
||||||
}
|
}
|
||||||
client->SetState(ClientStateSynchronizeStart::Instance());
|
client->SetState(ClientStateSynchronizeStart::Instance());
|
||||||
} else if (managementMsg.messagetype() == GameManagementMessage::Type_InviteNotifyMessage) {
|
|
||||||
const InviteNotifyMessage &netInvNotify = managementMsg.invitenotifymessage();
|
|
||||||
client->GetCallback().SignalPlayerGameInvitation(
|
|
||||||
netInvNotify.gameid(),
|
|
||||||
netInvNotify.playeridwho(),
|
|
||||||
netInvNotify.playeridbywhom());
|
|
||||||
} else if (managementMsg.messagetype() == GameManagementMessage::Type_RejectInvNotifyMessage) {
|
|
||||||
const RejectInvNotifyMessage &netRejNotify = tmpPacket->GetMsg()->rejectinvnotifymessage();
|
|
||||||
client->GetCallback().SignalRejectedGameInvitation(
|
|
||||||
netRejNotify.gameid(),
|
|
||||||
netRejNotify.playerid(),
|
|
||||||
static_cast<DenyGameInvitationReason>(netRejNotify.playerrejectreason()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1493,9 +1518,13 @@ ClientStateSynchronizeStart::TimerLoop(const boost::system::error_code& ec, boos
|
|||||||
if (client->IsSynchronized()) {
|
if (client->IsSynchronized()) {
|
||||||
// Acknowledge start.
|
// Acknowledge start.
|
||||||
boost::shared_ptr<NetPacket> startAck(new NetPacket);
|
boost::shared_ptr<NetPacket> startAck(new NetPacket);
|
||||||
startAck->GetMsg()->set_messagetype(PokerTHMessage::Type_StartEventAckMessage);
|
startAck->GetMsg()->set_messagetype(PokerTHMessage::Type_GameMessage);
|
||||||
StartEventAckMessage *netStartAck = startAck->GetMsg()->mutable_starteventackmessage();
|
GameMessage *netGame = startAck->GetMsg()->mutable_gamemessage();
|
||||||
netStartAck->set_gameid(client->GetGameId());
|
netGame->set_gameid(client->GetGameId());
|
||||||
|
netGame->set_messagetype(GameMessage::Type_GameManagementMessage);
|
||||||
|
GameManagementMessage *netManage = netGame->mutable_gamemanagementmessage();
|
||||||
|
netManage->set_messagetype(GameManagementMessage::Type_StartEventAckMessage);
|
||||||
|
/*StartEventAckMessage *netStartAck = */netManage->mutable_starteventackmessage();
|
||||||
|
|
||||||
client->GetSender().Send(client->GetContext().GetSessionData(), startAck);
|
client->GetSender().Send(client->GetContext().GetSessionData(), startAck);
|
||||||
// Unsubscribe lobby messages.
|
// Unsubscribe lobby messages.
|
||||||
@@ -1513,15 +1542,19 @@ ClientStateSynchronizeStart::TimerLoop(const boost::system::error_code& ec, boos
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientStateSynchronizeStart::InternalHandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket)
|
ClientStateSynchronizeStart::InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg)
|
||||||
{
|
{
|
||||||
if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_GameStartInitialMessage) {
|
if (gameMsg.messagetype() == GameMessage::Type_GameManagementMessage) {
|
||||||
|
const GameManagementMessage &managementMsg = gameMsg.gamemanagementmessage();
|
||||||
|
if (managementMsg.messagetype() == GameManagementMessage::Type_GameStartInitialMessage) {
|
||||||
|
/*const GameStartInitialMessage &netStartInitial = managementMsg.gamestartinitialmessage();*/
|
||||||
// Try to start anyway. Terminating here is very bad because rejoin is not possible then.
|
// Try to start anyway. Terminating here is very bad because rejoin is not possible then.
|
||||||
// Unsubscribe lobby messages.
|
// Unsubscribe lobby messages.
|
||||||
client->UnsubscribeLobbyMsg();
|
client->UnsubscribeLobbyMsg();
|
||||||
client->SetState(ClientStateWaitStart::Instance());
|
client->SetState(ClientStateWaitStart::Instance());
|
||||||
// Forward the game start message to the next state.
|
// Forward the game start message to the next state.
|
||||||
client->GetState().HandlePacket(client, tmpPacket);
|
ClientStateWaitStart::Instance().HandleGameMsg(client, gameMsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1553,16 +1586,18 @@ ClientStateWaitStart::Exit(boost::shared_ptr<ClientThread> /*client*/)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientStateWaitStart::InternalHandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket)
|
ClientStateWaitStart::InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg)
|
||||||
{
|
{
|
||||||
if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_GameStartInitialMessage
|
if (gameMsg.messagetype() == GameMessage::Type_GameManagementMessage) {
|
||||||
|| tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_GameStartRejoinMessage) {
|
const GameManagementMessage &managementMsg = gameMsg.gamemanagementmessage();
|
||||||
|
if (managementMsg.messagetype() == GameManagementMessage::Type_GameStartInitialMessage
|
||||||
|
|| managementMsg.messagetype() == GameManagementMessage::Type_GameStartRejoinMessage) {
|
||||||
PlayerIdList tmpPlayerList;
|
PlayerIdList tmpPlayerList;
|
||||||
unsigned tmpHandId = 0;
|
unsigned tmpHandId = 0;
|
||||||
|
|
||||||
if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_GameStartInitialMessage) {
|
if (managementMsg.messagetype() == GameManagementMessage::Type_GameStartInitialMessage) {
|
||||||
// Start the network game as client.
|
// Start the network game as client.
|
||||||
const GameStartInitialMessage &netStartModeInitial = tmpPacket->GetMsg()->gamestartinitialmessage();
|
const GameStartInitialMessage &netStartModeInitial = managementMsg.gamestartinitialmessage();
|
||||||
|
|
||||||
StartData startData;
|
StartData startData;
|
||||||
startData.startDealerPlayerId = netStartModeInitial.startdealerplayerid();
|
startData.startDealerPlayerId = netStartModeInitial.startdealerplayerid();
|
||||||
@@ -1583,8 +1618,8 @@ ClientStateWaitStart::InternalHandlePacket(boost::shared_ptr<ClientThread> clien
|
|||||||
} else {
|
} else {
|
||||||
throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_COUNT, 0);
|
throw ClientException(__FILE__, __LINE__, ERR_NET_INVALID_PLAYER_COUNT, 0);
|
||||||
}
|
}
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_GameStartRejoinMessage) {
|
} else if (managementMsg.messagetype() == GameManagementMessage::Type_GameStartRejoinMessage) {
|
||||||
const GameStartRejoinMessage &netStartModeRejoin = tmpPacket->GetMsg()->gamestartrejoinmessage();
|
const GameStartRejoinMessage &netStartModeRejoin = managementMsg.gamestartrejoinmessage();
|
||||||
|
|
||||||
StartData startData;
|
StartData startData;
|
||||||
startData.startDealerPlayerId = netStartModeRejoin.startdealerplayerid();
|
startData.startDealerPlayerId = netStartModeRejoin.startdealerplayerid();
|
||||||
@@ -1621,6 +1656,7 @@ ClientStateWaitStart::InternalHandlePacket(boost::shared_ptr<ClientThread> clien
|
|||||||
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_START);
|
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_START);
|
||||||
client->SetState(ClientStateWaitHand::Instance());
|
client->SetState(ClientStateWaitHand::Instance());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -1651,12 +1687,53 @@ ClientStateWaitHand::Exit(boost::shared_ptr<ClientThread> /*client*/)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket)
|
ClientStateWaitHand::InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg)
|
||||||
{
|
{
|
||||||
if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_HandStartMessage) {
|
if (gameMsg.messagetype() == GameMessage::Type_GameManagementMessage) {
|
||||||
|
const GameManagementMessage &managementMsg = gameMsg.gamemanagementmessage();
|
||||||
|
if (managementMsg.messagetype() == GameManagementMessage::Type_EndOfGameMessage)
|
||||||
|
{
|
||||||
|
boost::shared_ptr<Game> curGame = client->GetGame();
|
||||||
|
if (curGame) {
|
||||||
|
const EndOfGameMessage &netEndOfGame = managementMsg.endofgamemessage();
|
||||||
|
|
||||||
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(netEndOfGame.winnerplayerid());
|
||||||
|
if (!tmpPlayer)
|
||||||
|
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
client->GetGui().logPlayerWinGame(tmpPlayer->getMyName(), curGame->getMyGameID());
|
||||||
|
// Resubscribe Lobby messages.
|
||||||
|
client->ResubscribeLobbyMsg();
|
||||||
|
// Show Lobby dialog.
|
||||||
|
client->GetCallback().SignalNetClientWaitDialog();
|
||||||
|
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_END);
|
||||||
|
client->SetState(ClientStateWaitGame::Instance());
|
||||||
|
}
|
||||||
|
} else if (managementMsg.messagetype() == GameManagementMessage::Type_PlayerIdChangedMessage) {
|
||||||
|
boost::shared_ptr<Game> curGame = client->GetGame();
|
||||||
|
if (curGame) {
|
||||||
|
// Perform Id change.
|
||||||
|
const PlayerIdChangedMessage &idChanged = managementMsg.playeridchangedmessage();
|
||||||
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(idChanged.oldplayerid());
|
||||||
|
if (!tmpPlayer)
|
||||||
|
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
||||||
|
tmpPlayer->setMyUniqueID(idChanged.newplayerid());
|
||||||
|
// This player is now active again.
|
||||||
|
tmpPlayer->setMyStayOnTableStatus(true);
|
||||||
|
// Also update the dealer, if necessary.
|
||||||
|
curGame->replaceDealer(idChanged.oldplayerid(), idChanged.newplayerid());
|
||||||
|
// Update the player name, if necessary.
|
||||||
|
PlayerInfo info;
|
||||||
|
if (client->GetCachedPlayerInfo(idChanged.newplayerid(), info)) {
|
||||||
|
tmpPlayer->setMyName(info.playerName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (gameMsg.messagetype() == GameMessage::Type_GameEngineMessage) {
|
||||||
|
const GameEngineMessage &engineMsg = gameMsg.gameenginemessage();
|
||||||
|
if (engineMsg.messagetype() == GameEngineMessage::Type_HandStartMessage) {
|
||||||
// Hand was started.
|
// Hand was started.
|
||||||
// These are the cards. Good luck.
|
// These are the cards. Good luck.
|
||||||
const HandStartMessage &netHandStart = tmpPacket->GetMsg()->handstartmessage();
|
const HandStartMessage &netHandStart = engineMsg.handstartmessage();
|
||||||
int myCards[2];
|
int myCards[2];
|
||||||
string userPassword(client->GetContext().GetPassword());
|
string userPassword(client->GetContext().GetPassword());
|
||||||
if (netHandStart.has_plaincards() && userPassword.empty()) {
|
if (netHandStart.has_plaincards() && userPassword.empty()) {
|
||||||
@@ -1724,24 +1801,8 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client
|
|||||||
|
|
||||||
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_HAND_START);
|
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_HAND_START);
|
||||||
client->SetState(ClientStateRunHand::Instance());
|
client->SetState(ClientStateRunHand::Instance());
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_EndOfGameMessage) {
|
} else if (engineMsg.messagetype() == GameEngineMessage::Type_AfterHandShowCardsMessage) {
|
||||||
boost::shared_ptr<Game> curGame = client->GetGame();
|
const AfterHandShowCardsMessage &showCards = engineMsg.afterhandshowcardsmessage();
|
||||||
if (curGame) {
|
|
||||||
const EndOfGameMessage &netEndOfGame = tmpPacket->GetMsg()->endofgamemessage();
|
|
||||||
|
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(netEndOfGame.winnerplayerid());
|
|
||||||
if (!tmpPlayer)
|
|
||||||
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
|
||||||
client->GetGui().logPlayerWinGame(tmpPlayer->getMyName(), curGame->getMyGameID());
|
|
||||||
// Resubscribe Lobby messages.
|
|
||||||
client->ResubscribeLobbyMsg();
|
|
||||||
// Show Lobby dialog.
|
|
||||||
client->GetCallback().SignalNetClientWaitDialog();
|
|
||||||
client->GetCallback().SignalNetClientGameInfo(MSG_NET_GAME_CLIENT_END);
|
|
||||||
client->SetState(ClientStateWaitGame::Instance());
|
|
||||||
}
|
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_AfterHandShowCardsMessage) {
|
|
||||||
const AfterHandShowCardsMessage &showCards = tmpPacket->GetMsg()->afterhandshowcardsmessage();
|
|
||||||
const PlayerResult &r = showCards.playerresult();
|
const PlayerResult &r = showCards.playerresult();
|
||||||
|
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = client->GetGame()->getPlayerByUniqueId(r.playerid());
|
boost::shared_ptr<PlayerInterface> tmpPlayer = client->GetGame()->getPlayerByUniqueId(r.playerid());
|
||||||
@@ -1765,24 +1826,6 @@ ClientStateWaitHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client
|
|||||||
|
|
||||||
client->GetCallback().SignalNetClientPostRiverShowCards(r.playerid());
|
client->GetCallback().SignalNetClientPostRiverShowCards(r.playerid());
|
||||||
client->GetClientLog()->logHoleCardsHandName(client->GetGame()->getActivePlayerList(), tmpPlayer, true);
|
client->GetClientLog()->logHoleCardsHandName(client->GetGame()->getActivePlayerList(), tmpPlayer, true);
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_PlayerIdChangedMessage) {
|
|
||||||
boost::shared_ptr<Game> curGame = client->GetGame();
|
|
||||||
if (curGame) {
|
|
||||||
// Perform Id change.
|
|
||||||
const PlayerIdChangedMessage &idChanged = tmpPacket->GetMsg()->playeridchangedmessage();
|
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(idChanged.oldplayerid());
|
|
||||||
if (!tmpPlayer)
|
|
||||||
throw ClientException(__FILE__, __LINE__, ERR_NET_UNKNOWN_PLAYER_ID, 0);
|
|
||||||
tmpPlayer->setMyUniqueID(idChanged.newplayerid());
|
|
||||||
// This player is now active again.
|
|
||||||
tmpPlayer->setMyStayOnTableStatus(true);
|
|
||||||
// Also update the dealer, if necessary.
|
|
||||||
curGame->replaceDealer(idChanged.oldplayerid(), idChanged.newplayerid());
|
|
||||||
// Update the player name, if necessary.
|
|
||||||
PlayerInfo info;
|
|
||||||
if (client->GetCachedPlayerInfo(idChanged.newplayerid(), info)) {
|
|
||||||
tmpPlayer->setMyName(info.playerName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1815,11 +1858,13 @@ ClientStateRunHand::Exit(boost::shared_ptr<ClientThread> /*client*/)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client, boost::shared_ptr<NetPacket> tmpPacket)
|
ClientStateRunHand::InternalHandleGameMsg(boost::shared_ptr<ClientThread> client, const GameMessage &gameMsg)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<Game> curGame = client->GetGame();
|
boost::shared_ptr<Game> curGame = client->GetGame();
|
||||||
if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_PlayersActionDoneMessage) {
|
if (gameMsg.messagetype() == GameMessage::Type_GameEngineMessage) {
|
||||||
const PlayersActionDoneMessage &netActionDone = tmpPacket->GetMsg()->playersactiondonemessage();
|
const GameEngineMessage &engineMsg = gameMsg.gameenginemessage();
|
||||||
|
if (engineMsg.messagetype() == GameEngineMessage::Type_PlayersActionDoneMessage) {
|
||||||
|
const PlayersActionDoneMessage &netActionDone = engineMsg.playersactiondonemessage();
|
||||||
|
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(netActionDone.playerid());
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(netActionDone.playerid());
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
@@ -1871,11 +1916,11 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
|
|||||||
curGame->getPlayerByUniqueId(curGame->getCurrentHand()->getCurrentBeRo()->getBigBlindPositionId())->getMyName());
|
curGame->getPlayerByUniqueId(curGame->getCurrentHand()->getCurrentBeRo()->getBigBlindPositionId())->getMyName());
|
||||||
client->GetClientLog()->logNewHandMsg(
|
client->GetClientLog()->logNewHandMsg(
|
||||||
curGame->getCurrentHandID(),
|
curGame->getCurrentHandID(),
|
||||||
curGame->getPlayerByUniqueId(curGame->getCurrentHand()->getDealerPosition())->getMyID()+1,
|
curGame->getPlayerByUniqueId(curGame->getCurrentHand()->getDealerPosition())->getMyID() + 1,
|
||||||
curGame->getCurrentHand()->getSmallBlind(),
|
curGame->getCurrentHand()->getSmallBlind(),
|
||||||
curGame->getPlayerByUniqueId(curGame->getCurrentHand()->getCurrentBeRo()->getSmallBlindPositionId())->getMyID()+1,
|
curGame->getPlayerByUniqueId(curGame->getCurrentHand()->getCurrentBeRo()->getSmallBlindPositionId())->getMyID() + 1,
|
||||||
curGame->getCurrentHand()->getSmallBlind()*2,
|
curGame->getCurrentHand()->getSmallBlind() * 2,
|
||||||
curGame->getPlayerByUniqueId(curGame->getCurrentHand()->getCurrentBeRo()->getBigBlindPositionId())->getMyID()+1,
|
curGame->getPlayerByUniqueId(curGame->getCurrentHand()->getCurrentBeRo()->getBigBlindPositionId())->getMyID() + 1,
|
||||||
curGame->getSeatsList()
|
curGame->getSeatsList()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1895,8 +1940,8 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
|
|||||||
client->GetGui().refreshCash();
|
client->GetGui().refreshCash();
|
||||||
client->GetGui().refreshButton();
|
client->GetGui().refreshButton();
|
||||||
client->GetGui().updateMyButtonsState();
|
client->GetGui().updateMyButtonsState();
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_PlayersTurnMessage) {
|
} else if (engineMsg.messagetype() == GameEngineMessage::Type_PlayersTurnMessage) {
|
||||||
const PlayersTurnMessage &netPlayersTurn = tmpPacket->GetMsg()->playersturnmessage();
|
const PlayersTurnMessage &netPlayersTurn = engineMsg.playersturnmessage();
|
||||||
|
|
||||||
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(netPlayersTurn.playerid());
|
boost::shared_ptr<PlayerInterface> tmpPlayer = curGame->getPlayerByUniqueId(netPlayersTurn.playerid());
|
||||||
if (!tmpPlayer)
|
if (!tmpPlayer)
|
||||||
@@ -1929,8 +1974,8 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
|
|||||||
|
|
||||||
if (tmpPlayer->getMyID() == 0) // Is this the GUI player?
|
if (tmpPlayer->getMyID() == 0) // Is this the GUI player?
|
||||||
client->GetGui().meInAction();
|
client->GetGui().meInAction();
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_DealFlopCardsMessage) {
|
} else if (engineMsg.messagetype() == GameEngineMessage::Type_DealFlopCardsMessage) {
|
||||||
const DealFlopCardsMessage &netDealFlop = tmpPacket->GetMsg()->dealflopcardsmessage();
|
const DealFlopCardsMessage &netDealFlop = engineMsg.dealflopcardsmessage();
|
||||||
|
|
||||||
int tmpCards[5];
|
int tmpCards[5];
|
||||||
tmpCards[0] = static_cast<int>(netDealFlop.flopcard1());
|
tmpCards[0] = static_cast<int>(netDealFlop.flopcard1());
|
||||||
@@ -1948,8 +1993,8 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
|
|||||||
client->GetGui().refreshPot();
|
client->GetGui().refreshPot();
|
||||||
client->GetGui().refreshSet();
|
client->GetGui().refreshSet();
|
||||||
client->GetGui().dealBeRoCards(1);
|
client->GetGui().dealBeRoCards(1);
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_DealTurnCardMessage) {
|
} else if (engineMsg.messagetype() == GameEngineMessage::Type_DealTurnCardMessage) {
|
||||||
const DealTurnCardMessage &netDealTurn = tmpPacket->GetMsg()->dealturncardmessage();
|
const DealTurnCardMessage &netDealTurn = engineMsg.dealturncardmessage();
|
||||||
|
|
||||||
int tmpCards[5];
|
int tmpCards[5];
|
||||||
curGame->getCurrentHand()->getBoard()->getMyCards(tmpCards);
|
curGame->getCurrentHand()->getBoard()->getMyCards(tmpCards);
|
||||||
@@ -1965,8 +2010,8 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
|
|||||||
client->GetGui().refreshPot();
|
client->GetGui().refreshPot();
|
||||||
client->GetGui().refreshSet();
|
client->GetGui().refreshSet();
|
||||||
client->GetGui().dealBeRoCards(2);
|
client->GetGui().dealBeRoCards(2);
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_DealRiverCardMessage) {
|
} else if (engineMsg.messagetype() == GameEngineMessage::Type_DealRiverCardMessage) {
|
||||||
const DealRiverCardMessage &netDealRiver = tmpPacket->GetMsg()->dealrivercardmessage();
|
const DealRiverCardMessage &netDealRiver = engineMsg.dealrivercardmessage();
|
||||||
|
|
||||||
int tmpCards[5];
|
int tmpCards[5];
|
||||||
curGame->getCurrentHand()->getBoard()->getMyCards(tmpCards);
|
curGame->getCurrentHand()->getBoard()->getMyCards(tmpCards);
|
||||||
@@ -1982,8 +2027,8 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
|
|||||||
client->GetGui().refreshPot();
|
client->GetGui().refreshPot();
|
||||||
client->GetGui().refreshSet();
|
client->GetGui().refreshSet();
|
||||||
client->GetGui().dealBeRoCards(3);
|
client->GetGui().dealBeRoCards(3);
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_AllInShowCardsMessage) {
|
} else if (engineMsg.messagetype() == GameEngineMessage::Type_AllInShowCardsMessage) {
|
||||||
const AllInShowCardsMessage &netAllInShow = tmpPacket->GetMsg()->allinshowcardsmessage();
|
const AllInShowCardsMessage &netAllInShow = engineMsg.allinshowcardsmessage();
|
||||||
|
|
||||||
curGame->getCurrentHand()->setAllInCondition(true);
|
curGame->getCurrentHand()->setAllInCondition(true);
|
||||||
|
|
||||||
@@ -2003,13 +2048,13 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
|
|||||||
tmpPlayer->setMyHoleCards(tmpCards);
|
tmpPlayer->setMyHoleCards(tmpCards);
|
||||||
}
|
}
|
||||||
client->GetGui().flipHolecardsAllIn();
|
client->GetGui().flipHolecardsAllIn();
|
||||||
if(curGame->getCurrentHand()->getCurrentRound()<GAME_STATE_RIVER) {
|
if (curGame->getCurrentHand()->getCurrentRound() < GAME_STATE_RIVER) {
|
||||||
client->GetClientLog()->logHoleCardsHandName(
|
client->GetClientLog()->logHoleCardsHandName(
|
||||||
curGame->getActivePlayerList()
|
curGame->getActivePlayerList()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_EndOfHandHideCardsMessage) {
|
} else if (engineMsg.messagetype() == GameEngineMessage::Type_EndOfHandHideCardsMessage) {
|
||||||
const EndOfHandHideCardsMessage &hideCards = tmpPacket->GetMsg()->endofhandhidecardsmessage();
|
const EndOfHandHideCardsMessage &hideCards = engineMsg.endofhandhidecardsmessage();
|
||||||
curGame->getCurrentHand()->getBoard()->collectPot();
|
curGame->getCurrentHand()->getBoard()->collectPot();
|
||||||
// Reset player sets
|
// Reset player sets
|
||||||
ResetPlayerSets(*curGame);
|
ResetPlayerSets(*curGame);
|
||||||
@@ -2044,8 +2089,8 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
|
|||||||
client->GetClientLog()->logPlayerSitsOut(curGame->getActivePlayerList());
|
client->GetClientLog()->logPlayerSitsOut(curGame->getActivePlayerList());
|
||||||
client->GetClientLog()->logGameWinner(curGame->getActivePlayerList());
|
client->GetClientLog()->logGameWinner(curGame->getActivePlayerList());
|
||||||
client->GetClientLog()->logAfterHand();
|
client->GetClientLog()->logAfterHand();
|
||||||
} else if (tmpPacket->GetMsg()->messagetype() == PokerTHMessage::Type_EndOfHandShowCardsMessage) {
|
} else if (engineMsg.messagetype() == GameEngineMessage::Type_EndOfHandShowCardsMessage) {
|
||||||
const EndOfHandShowCardsMessage &showCards = tmpPacket->GetMsg()->endofhandshowcardsmessage();
|
const EndOfHandShowCardsMessage &showCards = engineMsg.endofhandshowcardsmessage();
|
||||||
|
|
||||||
curGame->getCurrentHand()->getBoard()->collectPot();
|
curGame->getCurrentHand()->getBoard()->collectPot();
|
||||||
// Reset player sets
|
// Reset player sets
|
||||||
@@ -2111,6 +2156,7 @@ ClientStateRunHand::InternalHandlePacket(boost::shared_ptr<ClientThread> client,
|
|||||||
client->GetClientLog()->logGameWinner(curGame->getActivePlayerList());
|
client->GetClientLog()->logGameWinner(curGame->getActivePlayerList());
|
||||||
client->GetClientLog()->logAfterHand();
|
client->GetClientLog()->logAfterHand();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Synchronize with GUI.
|
// Synchronize with GUI.
|
||||||
client->GetGui().waitForGuiUpdateDone();
|
client->GetGui().waitForGuiUpdateDone();
|
||||||
|
|||||||
+151
-64
@@ -128,9 +128,13 @@ void
|
|||||||
ClientThread::SendKickPlayer(unsigned playerId)
|
ClientThread::SendKickPlayer(unsigned playerId)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_KickPlayerRequestMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameMessage);
|
||||||
KickPlayerRequestMessage *netKick = packet->GetMsg()->mutable_kickplayerrequestmessage();
|
GameMessage *netGame = packet->GetMsg()->mutable_gamemessage();
|
||||||
netKick->set_gameid(GetGameId());
|
netGame->set_gameid(GetGameId());
|
||||||
|
netGame->set_messagetype(GameMessage::Type_GameManagementMessage);
|
||||||
|
GameManagementMessage *netManage = netGame->mutable_gamemanagementmessage();
|
||||||
|
netManage->set_messagetype(GameManagementMessage::Type_KickPlayerRequestMessage);
|
||||||
|
KickPlayerRequestMessage *netKick = netManage->mutable_kickplayerrequestmessage();
|
||||||
netKick->set_playerid(playerId);
|
netKick->set_playerid(playerId);
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
}
|
}
|
||||||
@@ -139,9 +143,13 @@ void
|
|||||||
ClientThread::SendLeaveCurrentGame()
|
ClientThread::SendLeaveCurrentGame()
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LeaveGameRequestMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameMessage);
|
||||||
LeaveGameRequestMessage *netLeave = packet->GetMsg()->mutable_leavegamerequestmessage();
|
GameMessage *netGame = packet->GetMsg()->mutable_gamemessage();
|
||||||
netLeave->set_gameid(GetGameId());
|
netGame->set_gameid(GetGameId());
|
||||||
|
netGame->set_messagetype(GameMessage::Type_GameManagementMessage);
|
||||||
|
GameManagementMessage *netManage = netGame->mutable_gamemanagementmessage();
|
||||||
|
netManage->set_messagetype(GameManagementMessage::Type_LeaveGameRequestMessage);
|
||||||
|
/*LeaveGameRequestMessage *netLeave = */netManage->mutable_leavegamerequestmessage();
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,10 +159,14 @@ ClientThread::SendStartEvent(bool fillUpWithCpuPlayers)
|
|||||||
// Warning: This function is called in the context of the GUI thread.
|
// Warning: This function is called in the context of the GUI thread.
|
||||||
// Create a network packet for the server start event.
|
// Create a network packet for the server start event.
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_StartEventMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameMessage);
|
||||||
StartEventMessage *netStartEvent = packet->GetMsg()->mutable_starteventmessage();
|
GameMessage *netGame = packet->GetMsg()->mutable_gamemessage();
|
||||||
|
netGame->set_gameid(GetGameId());
|
||||||
|
netGame->set_messagetype(GameMessage::Type_GameManagementMessage);
|
||||||
|
GameManagementMessage *netManage = netGame->mutable_gamemanagementmessage();
|
||||||
|
netManage->set_messagetype(GameManagementMessage::Type_StartEventMessage);
|
||||||
|
StartEventMessage *netStartEvent = netManage->mutable_starteventmessage();
|
||||||
netStartEvent->set_starteventtype(StartEventMessage::startEvent);
|
netStartEvent->set_starteventtype(StartEventMessage::startEvent);
|
||||||
netStartEvent->set_gameid(GetGameId());
|
|
||||||
netStartEvent->set_fillwithcomputerplayers(fillUpWithCpuPlayers);
|
netStartEvent->set_fillwithcomputerplayers(fillUpWithCpuPlayers);
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
}
|
}
|
||||||
@@ -169,9 +181,13 @@ ClientThread::SendPlayerAction()
|
|||||||
m_pingData.StartPing();
|
m_pingData.StartPing();
|
||||||
}
|
}
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_MyActionRequestMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameMessage);
|
||||||
MyActionRequestMessage *netMyAction = packet->GetMsg()->mutable_myactionrequestmessage();
|
GameMessage *netGame = packet->GetMsg()->mutable_gamemessage();
|
||||||
netMyAction->set_gameid(GetGameId());
|
netGame->set_gameid(GetGameId());
|
||||||
|
netGame->set_messagetype(GameMessage::Type_GameEngineMessage);
|
||||||
|
GameEngineMessage *netEngine = netGame->mutable_gameenginemessage();
|
||||||
|
netEngine->set_messagetype(GameEngineMessage::Type_MyActionRequestMessage);
|
||||||
|
MyActionRequestMessage *netMyAction = netEngine->mutable_myactionrequestmessage();
|
||||||
boost::shared_ptr<PlayerInterface> myPlayer = GetGame()->getSeatsList()->front();
|
boost::shared_ptr<PlayerInterface> myPlayer = GetGame()->getSeatsList()->front();
|
||||||
netMyAction->set_handnum(GetGame()->getCurrentHandID());
|
netMyAction->set_handnum(GetGame()->getCurrentHandID());
|
||||||
netMyAction->set_gamestate(static_cast<NetGameState>(GetGame()->getCurrentHand()->getCurrentRound()));
|
netMyAction->set_gamestate(static_cast<NetGameState>(GetGame()->getCurrentHand()->getCurrentRound()));
|
||||||
@@ -191,9 +207,13 @@ ClientThread::SendGameChatMessage(const std::string &msg)
|
|||||||
// Warning: This function is called in the context of the GUI thread.
|
// Warning: This function is called in the context of the GUI thread.
|
||||||
// Create a network packet containing the chat message.
|
// Create a network packet containing the chat message.
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_ChatRequestMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameMessage);
|
||||||
ChatRequestMessage *netChat = packet->GetMsg()->mutable_chatrequestmessage();
|
GameMessage *netGame = packet->GetMsg()->mutable_gamemessage();
|
||||||
netChat->set_targetgameid(GetGameId());
|
netGame->set_gameid(GetGameId());
|
||||||
|
netGame->set_messagetype(GameMessage::Type_GameManagementMessage);
|
||||||
|
GameManagementMessage *netManage = netGame->mutable_gamemanagementmessage();
|
||||||
|
netManage->set_messagetype(GameManagementMessage::Type_ChatRequestMessage);
|
||||||
|
ChatRequestMessage *netChat = netManage->mutable_chatrequestmessage();
|
||||||
netChat->set_chattext(msg);
|
netChat->set_chattext(msg);
|
||||||
|
|
||||||
// Just dump the packet.
|
// Just dump the packet.
|
||||||
@@ -206,8 +226,10 @@ ClientThread::SendLobbyChatMessage(const std::string &msg)
|
|||||||
// Warning: This function is called in the context of the GUI thread.
|
// Warning: This function is called in the context of the GUI thread.
|
||||||
// Create a network packet containing the chat message.
|
// Create a network packet containing the chat message.
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_ChatRequestMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
ChatRequestMessage *netChat = packet->GetMsg()->mutable_chatrequestmessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_ChatRequestMessage);
|
||||||
|
ChatRequestMessage *netChat = netLobby->mutable_chatrequestmessage();
|
||||||
netChat->set_chattext(msg);
|
netChat->set_chattext(msg);
|
||||||
|
|
||||||
// Just dump the packet.
|
// Just dump the packet.
|
||||||
@@ -220,8 +242,10 @@ ClientThread::SendPrivateChatMessage(unsigned targetPlayerId, const std::string
|
|||||||
// Warning: This function is called in the context of the GUI thread.
|
// Warning: This function is called in the context of the GUI thread.
|
||||||
// Create a network packet containing the chat message.
|
// Create a network packet containing the chat message.
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_ChatRequestMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
ChatRequestMessage *netChat = packet->GetMsg()->mutable_chatrequestmessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_ChatRequestMessage);
|
||||||
|
ChatRequestMessage *netChat = netLobby->mutable_chatrequestmessage();
|
||||||
netChat->set_targetplayerid(targetPlayerId);
|
netChat->set_targetplayerid(targetPlayerId);
|
||||||
netChat->set_chattext(msg);
|
netChat->set_chattext(msg);
|
||||||
|
|
||||||
@@ -235,9 +259,13 @@ ClientThread::SendJoinFirstGame(const std::string &password, bool autoLeave)
|
|||||||
// Warning: This function is called in the context of the GUI thread.
|
// Warning: This function is called in the context of the GUI thread.
|
||||||
// Create a network packet to request joining a game.
|
// Create a network packet to request joining a game.
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_JoinExistingGameMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameMessage);
|
||||||
JoinExistingGameMessage *netJoinGame = packet->GetMsg()->mutable_joinexistinggamemessage();
|
GameMessage *netGame = packet->GetMsg()->mutable_gamemessage();
|
||||||
netJoinGame->set_gameid(1);
|
netGame->set_gameid(1);
|
||||||
|
netGame->set_messagetype(GameMessage::Type_GameManagementMessage);
|
||||||
|
GameManagementMessage *netManage = netGame->mutable_gamemanagementmessage();
|
||||||
|
netManage->set_messagetype(GameManagementMessage::Type_JoinGameMessage);
|
||||||
|
JoinGameMessage *netJoinGame = netManage->mutable_joingamemessage();
|
||||||
netJoinGame->set_autoleave(autoLeave);
|
netJoinGame->set_autoleave(autoLeave);
|
||||||
|
|
||||||
if (!password.empty()) {
|
if (!password.empty()) {
|
||||||
@@ -252,9 +280,13 @@ ClientThread::SendJoinGame(unsigned gameId, const std::string &password, bool au
|
|||||||
// Warning: This function is called in the context of the GUI thread.
|
// Warning: This function is called in the context of the GUI thread.
|
||||||
// Create a network packet to request joining a game.
|
// Create a network packet to request joining a game.
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_JoinExistingGameMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameMessage);
|
||||||
JoinExistingGameMessage *netJoinGame = packet->GetMsg()->mutable_joinexistinggamemessage();
|
GameMessage *netGame = packet->GetMsg()->mutable_gamemessage();
|
||||||
netJoinGame->set_gameid(gameId);
|
netGame->set_gameid(gameId);
|
||||||
|
netGame->set_messagetype(GameMessage::Type_GameManagementMessage);
|
||||||
|
GameManagementMessage *netManage = netGame->mutable_gamemanagementmessage();
|
||||||
|
netManage->set_messagetype(GameManagementMessage::Type_JoinGameMessage);
|
||||||
|
JoinGameMessage *netJoinGame = netManage->mutable_joingamemessage();
|
||||||
netJoinGame->set_autoleave(autoLeave);
|
netJoinGame->set_autoleave(autoLeave);
|
||||||
|
|
||||||
if (!password.empty()) {
|
if (!password.empty()) {
|
||||||
@@ -269,9 +301,13 @@ ClientThread::SendRejoinGame(unsigned gameId, bool autoLeave)
|
|||||||
// Warning: This function is called in the context of the GUI thread.
|
// Warning: This function is called in the context of the GUI thread.
|
||||||
// Create a network packet to request rejoining a running game.
|
// Create a network packet to request rejoining a running game.
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_RejoinExistingGameMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameMessage);
|
||||||
RejoinExistingGameMessage *netJoinGame = packet->GetMsg()->mutable_rejoinexistinggamemessage();
|
GameMessage *netGame = packet->GetMsg()->mutable_gamemessage();
|
||||||
netJoinGame->set_gameid(gameId);
|
netGame->set_gameid(gameId);
|
||||||
|
netGame->set_messagetype(GameMessage::Type_GameManagementMessage);
|
||||||
|
GameManagementMessage *netManage = netGame->mutable_gamemanagementmessage();
|
||||||
|
netManage->set_messagetype(GameManagementMessage::Type_RejoinGameMessage);
|
||||||
|
RejoinGameMessage *netJoinGame = netManage->mutable_rejoingamemessage();
|
||||||
netJoinGame->set_autoleave(autoLeave);
|
netJoinGame->set_autoleave(autoLeave);
|
||||||
|
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
@@ -283,15 +319,17 @@ ClientThread::SendCreateGame(const GameData &gameData, const std::string &name,
|
|||||||
// Warning: This function is called in the context of the GUI thread.
|
// Warning: This function is called in the context of the GUI thread.
|
||||||
// Create a network packet to request creating a new game.
|
// Create a network packet to request creating a new game.
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_JoinNewGameMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
JoinNewGameMessage *netJoinGame = packet->GetMsg()->mutable_joinnewgamemessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
netJoinGame->set_autoleave(autoLeave);
|
netLobby->set_messagetype(LobbyMessage::Type_CreateGameMessage);
|
||||||
NetGameInfo *gameInfo = netJoinGame->mutable_gameinfo();
|
CreateGameMessage *netCreateGame = netLobby->mutable_creategamemessage();
|
||||||
|
netCreateGame->set_autoleave(autoLeave);
|
||||||
|
NetGameInfo *gameInfo = netCreateGame->mutable_gameinfo();
|
||||||
NetPacket::SetGameData(gameData, *gameInfo);
|
NetPacket::SetGameData(gameData, *gameInfo);
|
||||||
gameInfo->set_gamename(name);
|
gameInfo->set_gamename(name);
|
||||||
|
|
||||||
if (!password.empty()) {
|
if (!password.empty()) {
|
||||||
netJoinGame->set_password(password);
|
netCreateGame->set_password(password);
|
||||||
}
|
}
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
}
|
}
|
||||||
@@ -300,8 +338,10 @@ void
|
|||||||
ClientThread::SendResetTimeout()
|
ClientThread::SendResetTimeout()
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_ResetTimeoutMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
packet->GetMsg()->mutable_resettimeoutmessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_ResetTimeoutMessage);
|
||||||
|
netLobby->mutable_resettimeoutmessage();
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,9 +349,13 @@ void
|
|||||||
ClientThread::SendAskKickPlayer(unsigned playerId)
|
ClientThread::SendAskKickPlayer(unsigned playerId)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_AskKickPlayerMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameMessage);
|
||||||
AskKickPlayerMessage *netAsk = packet->GetMsg()->mutable_askkickplayermessage();
|
GameMessage *netGame = packet->GetMsg()->mutable_gamemessage();
|
||||||
netAsk->set_gameid(GetGameId());
|
netGame->set_gameid(GetGameId());
|
||||||
|
netGame->set_messagetype(GameMessage::Type_GameManagementMessage);
|
||||||
|
GameManagementMessage *netManage = netGame->mutable_gamemanagementmessage();
|
||||||
|
netManage->set_messagetype(GameManagementMessage::Type_AskKickPlayerMessage);
|
||||||
|
AskKickPlayerMessage *netAsk = netManage->mutable_askkickplayermessage();
|
||||||
netAsk->set_playerid(playerId);
|
netAsk->set_playerid(playerId);
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
}
|
}
|
||||||
@@ -320,9 +364,13 @@ void
|
|||||||
ClientThread::SendVoteKick(bool doKick)
|
ClientThread::SendVoteKick(bool doKick)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_VoteKickRequestMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameMessage);
|
||||||
VoteKickRequestMessage *netVote = packet->GetMsg()->mutable_votekickrequestmessage();
|
GameMessage *netGame = packet->GetMsg()->mutable_gamemessage();
|
||||||
netVote->set_gameid(GetGameId());
|
netGame->set_gameid(GetGameId());
|
||||||
|
netGame->set_messagetype(GameMessage::Type_GameManagementMessage);
|
||||||
|
GameManagementMessage *netManage = netGame->mutable_gamemanagementmessage();
|
||||||
|
netManage->set_messagetype(GameManagementMessage::Type_VoteKickRequestMessage);
|
||||||
|
VoteKickRequestMessage *netVote = netManage->mutable_votekickrequestmessage();
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_curPetitionIdMutex);
|
boost::mutex::scoped_lock lock(m_curPetitionIdMutex);
|
||||||
netVote->set_petitionid(m_curPetitionId);
|
netVote->set_petitionid(m_curPetitionId);
|
||||||
@@ -335,8 +383,13 @@ void
|
|||||||
ClientThread::SendShowMyCards()
|
ClientThread::SendShowMyCards()
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_ShowMyCardsRequestMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_GameMessage);
|
||||||
packet->GetMsg()->mutable_showmycardsrequestmessage();
|
GameMessage *netGame = packet->GetMsg()->mutable_gamemessage();
|
||||||
|
netGame->set_gameid(GetGameId());
|
||||||
|
netGame->set_messagetype(GameMessage::Type_GameEngineMessage);
|
||||||
|
GameEngineMessage *netEngine = netGame->mutable_gameenginemessage();
|
||||||
|
netEngine->set_messagetype(GameEngineMessage::Type_ShowMyCardsRequestMessage);
|
||||||
|
netEngine->mutable_showmycardsrequestmessage();
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,8 +397,10 @@ void
|
|||||||
ClientThread::SendInvitePlayerToCurrentGame(unsigned playerId)
|
ClientThread::SendInvitePlayerToCurrentGame(unsigned playerId)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_InvitePlayerToGameMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
InvitePlayerToGameMessage *netInvite = packet->GetMsg()->mutable_inviteplayertogamemessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_InvitePlayerToGameMessage);
|
||||||
|
InvitePlayerToGameMessage *netInvite = netLobby->mutable_inviteplayertogamemessage();
|
||||||
netInvite->set_gameid(GetGameId());
|
netInvite->set_gameid(GetGameId());
|
||||||
netInvite->set_playerid(playerId);
|
netInvite->set_playerid(playerId);
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
@@ -355,8 +410,10 @@ void
|
|||||||
ClientThread::SendRejectGameInvitation(unsigned gameId, DenyGameInvitationReason reason)
|
ClientThread::SendRejectGameInvitation(unsigned gameId, DenyGameInvitationReason reason)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_RejectGameInvitationMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
RejectGameInvitationMessage *netReject = packet->GetMsg()->mutable_rejectgameinvitationmessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_RejectGameInvitationMessage);
|
||||||
|
RejectGameInvitationMessage *netReject = netLobby->mutable_rejectgameinvitationmessage();
|
||||||
netReject->set_gameid(gameId);
|
netReject->set_gameid(gameId);
|
||||||
netReject->set_myrejectreason(static_cast<RejectGameInvitationMessage::RejectGameInvReason>(reason));
|
netReject->set_myrejectreason(static_cast<RejectGameInvitationMessage::RejectGameInvReason>(reason));
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
@@ -366,8 +423,10 @@ void
|
|||||||
ClientThread::SendReportAvatar(unsigned reportedPlayerId, const std::string &avatarHash)
|
ClientThread::SendReportAvatar(unsigned reportedPlayerId, const std::string &avatarHash)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_ReportAvatarMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
ReportAvatarMessage *netReport = packet->GetMsg()->mutable_reportavatarmessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_ReportAvatarMessage);
|
||||||
|
ReportAvatarMessage *netReport = netLobby->mutable_reportavatarmessage();
|
||||||
netReport->set_reportedplayerid(reportedPlayerId);
|
netReport->set_reportedplayerid(reportedPlayerId);
|
||||||
MD5Buf tmpMD5;
|
MD5Buf tmpMD5;
|
||||||
if (tmpMD5.FromString(avatarHash) && !tmpMD5.IsZero()) {
|
if (tmpMD5.FromString(avatarHash) && !tmpMD5.IsZero()) {
|
||||||
@@ -381,8 +440,10 @@ void
|
|||||||
ClientThread::SendReportGameName(unsigned reportedGameId)
|
ClientThread::SendReportGameName(unsigned reportedGameId)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_ReportGameMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
ReportGameMessage *netReport = packet->GetMsg()->mutable_reportgamemessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_ReportGameMessage);
|
||||||
|
ReportGameMessage *netReport = netLobby->mutable_reportgamemessage();
|
||||||
netReport->set_reportedgameid(reportedGameId);
|
netReport->set_reportedgameid(reportedGameId);
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
}
|
}
|
||||||
@@ -391,8 +452,10 @@ void
|
|||||||
ClientThread::SendAdminRemoveGame(unsigned removeGameId)
|
ClientThread::SendAdminRemoveGame(unsigned removeGameId)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_AdminRemoveGameMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
AdminRemoveGameMessage *netRemove = packet->GetMsg()->mutable_adminremovegamemessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_AdminRemoveGameMessage);
|
||||||
|
AdminRemoveGameMessage *netRemove = netLobby->mutable_adminremovegamemessage();
|
||||||
netRemove->set_removegameid(removeGameId);
|
netRemove->set_removegameid(removeGameId);
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
}
|
}
|
||||||
@@ -401,8 +464,10 @@ void
|
|||||||
ClientThread::SendAdminBanPlayer(unsigned playerId)
|
ClientThread::SendAdminBanPlayer(unsigned playerId)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_AdminBanPlayerMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
AdminBanPlayerMessage *netBan = packet->GetMsg()->mutable_adminbanplayermessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_AdminBanPlayerMessage);
|
||||||
|
AdminBanPlayerMessage *netBan = netLobby->mutable_adminbanplayermessage();
|
||||||
netBan->set_banplayerid(playerId);
|
netBan->set_banplayerid(playerId);
|
||||||
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
m_ioService->post(boost::bind(&ClientThread::SendSessionPacket, shared_from_this(), packet));
|
||||||
}
|
}
|
||||||
@@ -422,7 +487,21 @@ ClientThread::CloseSession(boost::shared_ptr<SessionData> /*session*/)
|
|||||||
void
|
void
|
||||||
ClientThread::HandlePacket(boost::shared_ptr<SessionData> /*session*/, boost::shared_ptr<NetPacket> packet)
|
ClientThread::HandlePacket(boost::shared_ptr<SessionData> /*session*/, boost::shared_ptr<NetPacket> packet)
|
||||||
{
|
{
|
||||||
GetState().HandlePacket(shared_from_this(), packet);
|
switch (packet->GetMsg()->messagetype())
|
||||||
|
{
|
||||||
|
case PokerTHMessage::Type_AnnounceMessage :
|
||||||
|
GetState().HandleAnnounceMsg(shared_from_this(), packet->GetMsg()->announcemessage());
|
||||||
|
break;
|
||||||
|
case PokerTHMessage::Type_AuthMessage :
|
||||||
|
GetState().HandleAuthMsg(shared_from_this(), packet->GetMsg()->authmessage());
|
||||||
|
break;
|
||||||
|
case PokerTHMessage::Type_GameMessage :
|
||||||
|
GetState().HandleGameMsg(shared_from_this(), packet->GetMsg()->gamemessage());
|
||||||
|
break;
|
||||||
|
case PokerTHMessage::Type_LobbyMessage :
|
||||||
|
GetState().HandleLobbyMsg(shared_from_this(), packet->GetMsg()->lobbymessage());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -700,8 +779,10 @@ void
|
|||||||
ClientThread::RequestPlayerInfo(const list<unsigned> &idList, bool requestAvatar)
|
ClientThread::RequestPlayerInfo(const list<unsigned> &idList, bool requestAvatar)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_PlayerInfoRequestMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
PlayerInfoRequestMessage *netPlayerInfo = packet->GetMsg()->mutable_playerinforequestmessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_PlayerInfoRequestMessage);
|
||||||
|
PlayerInfoRequestMessage *netPlayerInfo = netLobby->mutable_playerinforequestmessage();
|
||||||
BOOST_FOREACH(unsigned playerId, idList) {
|
BOOST_FOREACH(unsigned playerId, idList) {
|
||||||
if (find(m_playerInfoRequestList.begin(), m_playerInfoRequestList.end(), playerId) == m_playerInfoRequestList.end()) {
|
if (find(m_playerInfoRequestList.begin(), m_playerInfoRequestList.end(), playerId) == m_playerInfoRequestList.end()) {
|
||||||
netPlayerInfo->add_playerid(playerId);
|
netPlayerInfo->add_playerid(playerId);
|
||||||
@@ -812,8 +893,10 @@ ClientThread::RetrieveAvatarIfNeeded(unsigned id, const PlayerInfo &info)
|
|||||||
id, avatarServerAddress + serverFileName, GetContext().GetCacheDir() + TEMP_AVATAR_FILENAME);
|
id, avatarServerAddress + serverFileName, GetContext().GetCacheDir() + TEMP_AVATAR_FILENAME);
|
||||||
} else {
|
} else {
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_AvatarRequestMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
AvatarRequestMessage *netAvatar = packet->GetMsg()->mutable_avatarrequestmessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_AvatarRequestMessage);
|
||||||
|
AvatarRequestMessage *netAvatar = netLobby->mutable_avatarrequestmessage();
|
||||||
netAvatar->set_requestid(id);
|
netAvatar->set_requestid(id);
|
||||||
netAvatar->set_avatarhash(info.avatar.GetData(), MD5_DATA_SIZE);
|
netAvatar->set_avatarhash(info.avatar.GetData(), MD5_DATA_SIZE);
|
||||||
GetSender().Send(GetContext().GetSessionData(), packet);
|
GetSender().Send(GetContext().GetSessionData(), packet);
|
||||||
@@ -929,8 +1012,10 @@ ClientThread::UnsubscribeLobbyMsg()
|
|||||||
if (GetContext().GetSubscribeLobbyMsg()) {
|
if (GetContext().GetSubscribeLobbyMsg()) {
|
||||||
// Send unsubscribe request.
|
// Send unsubscribe request.
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_SubscriptionRequestMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
SubscriptionRequestMessage *netRequest = packet->GetMsg()->mutable_subscriptionrequestmessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_SubscriptionRequestMessage);
|
||||||
|
SubscriptionRequestMessage *netRequest = netLobby->mutable_subscriptionrequestmessage();
|
||||||
netRequest->set_subscriptionaction(SubscriptionRequestMessage::unsubscribeGameList);
|
netRequest->set_subscriptionaction(SubscriptionRequestMessage::unsubscribeGameList);
|
||||||
GetSender().Send(GetContext().GetSessionData(), packet);
|
GetSender().Send(GetContext().GetSessionData(), packet);
|
||||||
GetContext().SetSubscribeLobbyMsg(false);
|
GetContext().SetSubscribeLobbyMsg(false);
|
||||||
@@ -945,8 +1030,10 @@ ClientThread::ResubscribeLobbyMsg()
|
|||||||
ClearGameInfoMap();
|
ClearGameInfoMap();
|
||||||
// Send resubscribe request.
|
// Send resubscribe request.
|
||||||
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
boost::shared_ptr<NetPacket> packet(new NetPacket);
|
||||||
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_SubscriptionRequestMessage);
|
packet->GetMsg()->set_messagetype(PokerTHMessage::Type_LobbyMessage);
|
||||||
SubscriptionRequestMessage *netRequest = packet->GetMsg()->mutable_subscriptionrequestmessage();
|
LobbyMessage *netLobby = packet->GetMsg()->mutable_lobbymessage();
|
||||||
|
netLobby->set_messagetype(LobbyMessage::Type_SubscriptionRequestMessage);
|
||||||
|
SubscriptionRequestMessage *netRequest = netLobby->mutable_subscriptionrequestmessage();
|
||||||
netRequest->set_subscriptionaction(SubscriptionRequestMessage::resubscribeGameList);
|
netRequest->set_subscriptionaction(SubscriptionRequestMessage::resubscribeGameList);
|
||||||
GetSender().Send(GetContext().GetSessionData(), packet);
|
GetSender().Send(GetContext().GetSessionData(), packet);
|
||||||
GetContext().SetSubscribeLobbyMsg(true);
|
GetContext().SetSubscribeLobbyMsg(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user